{"id":4742,"date":"2016-07-19T02:36:04","date_gmt":"2016-07-19T02:36:04","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=4742"},"modified":"2016-07-19T02:36:04","modified_gmt":"2016-07-19T02:36:04","slug":"fixing-error-syntaxerror-identifier-jest-already-declared-file-dist__tests__import-editions-test-js","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/fixing-error-syntaxerror-identifier-jest-already-declared-file-dist__tests__import-editions-test-js\/","title":{"rendered":"Fixing error: SyntaxError: Identifier &#8216;jest&#8217; has already been declared in file &#8216;dist\\__tests__\\import-editions-test.js&#8217;."},"content":{"rendered":"<p>The following error can occur using Jest:<\/p>\n<pre>\nUsing Jest CLI v13.2.3, jasmine2\n FAIL  dist\\__tests__\\import-editions-test.js (0s)\n\u25cf Runtime Error\n  - SyntaxError: Identifier 'jest' has already been declared in file 'dist\\__tests__\\import-editions-test.js'.\n\n    Make sure your preprocessor is set up correctly and ensure your 'preprocessorIgnorePatterns' configuration is correct: http:\/\/facebook.github.io\/jest\/docs\/api.html#preprocessorignorepatterns-array-string\n    If you are currently setting up Jest or modifying your preprocessor, try `jest --no-cache`.\n    Preprocessor: No preprocessor specified, consider installing 'babel-jest'.\n    Jest tried to the execute the following code:\n    \"use strict\";\n    const import_editions_1 = require('..\/import-editions');\n    const jest = require('jest');\n    jest.unmock('..\/import-editions');\n    describe('parseLine', () => {\n        it('parses the header part of the line', () => {\n            expect(import_editions_1.parseLine('abc')).toBe('abc');\n        });\n    });\n\n\n        at Runtime._runSourceText (node_modules\\jest-runtime\\build\\index.js:410:15)\n        at Runtime._execModule (node_modules\\jest-runtime\\build\\index.js:374:30)\n        at Runtime.requireModule (node_modules\\jest-runtime\\build\\index.js:210:14)\n        at jasmine2 (node_modules\\jest-jasmine2\\build\\index.js:293:11)\n        at Test.run (node_modules\\jest-cli\\build\\Test.js:50:12)\n        at promise.then.then.data (node_modules\\jest-cli\\build\\TestRunner.js:264:62)\n1 test suite failed, 0 tests passed (0 total in 1 test suite, run time 1.086s)\nnpm ERR! Test failed.  See above for more details.\n<\/pre>\n<p>This indicates that you tried to import Jest into your file &#8211; it is implicitly added for you as a global when you run tests. So, don&#8217;t do this:<\/p>\n<pre lang=\"javascript\">\nconst jest = require('jest');\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Fixing a require error with jest<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9],"tags":[302],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/4742"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=4742"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/4742\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=4742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=4742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=4742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}