{"id":4739,"date":"2016-07-19T02:34:10","date_gmt":"2016-07-19T02:34:10","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=4739"},"modified":"2016-07-19T02:34:10","modified_gmt":"2016-07-19T02:34:10","slug":"fixing-error-cannot-find-module-jest-import-editions-test-js","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/fixing-error-cannot-find-module-jest-import-editions-test-js\/","title":{"rendered":"Fixing error : Cannot find module &#8216;jest&#8217; from &#8216;import-editions-test.js&#8217;"},"content":{"rendered":"<p>If you try to use ES6 import syntax with Jest, you can get the following error:<\/p>\n<pre lang=\"javascript\">\nimport { describe } from 'jest';\n<\/pre>\n<pre>\nUsing Jest CLI v13.2.3, jasmine2\n FAIL  dist\\__tests__\\import-editions-test.js (0s)\n\u25cf Runtime Error\n  - Error: Cannot find module 'jest' from 'import-editions-test.js'\n        at Resolver.resolveModule (node_modules\\jest-resolve\\build\\index.js:197:17)\n        at Runtime._resolveModule (node_modules\\jest-runtime\\build\\index.js:327:32)\n        at Runtime._normalizeID (node_modules\\jest-runtime\\build\\index.js:492:31)\n        at Runtime._shouldMock (node_modules\\jest-runtime\\build\\index.js:536:27)\n        at Runtime.requireModuleOrMock (node_modules\\jest-runtime\\build\\index.js:271:14)\n        at Object.<anonymous> (dist\\__tests__\\import-editions-test.js:3:16)\n        at Runtime._execModule (node_modules\\jest-runtime\\build\\index.js:375:17)\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)\n1 test suite failed, 0 tests passed (0 total in 1 test suite, run time 0.983s)\nnpm ERR! Test failed.  See above for more details.\n<\/pre>\n<p>Unfortunately this seems to mean that you can&#8217;t use ES6 imports at all, which means losing TypeScript bindings. To fix this, you can just remove the &#8216;import&#8217; and it should work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fixing an error loading Jest files<\/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":[4],"tags":[302],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/4739"}],"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=4739"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/4739\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=4739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=4739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=4739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}