{"id":4730,"date":"2016-07-19T01:50:56","date_gmt":"2016-07-19T01:50:56","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=4730"},"modified":"2016-07-19T01:50:56","modified_gmt":"2016-07-19T01:50:56","slug":"changing-path-files-jest-unit-tests","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/changing-path-files-jest-unit-tests\/","title":{"rendered":"Changing path of files in Jest unit tests"},"content":{"rendered":"<p>If you want to control where Jest looks for tests, you can simply add a &#8220;jest&#8221; section to package.json, and set &#8220;testPathDirs&#8221;. There are a whole bunch of other options in the documentation<sup><a href=\"#footnote_0_4730\" id=\"identifier_0_4730\" class=\"footnote-link footnote-identifier-link\" title=\"https:\/\/facebook.github.io\/jest\/docs\/api.html#testpathdirs-array-string\">1<\/a><\/sup><\/p>\n<pre lang=\"javascript\">\n{\n  \"name\": \"books\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"import-editions.tsx\",\n  \"scripts\": {\n    \"test\": \"jest\"\n  },\n  \"jest\": { \n    \"testPathDirs\": [\"dist\/__test__\/\"] \n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"bluebird\": \"^3.4.1\",\n    \"lodash\": \"^4.13.1\",\n    \"rethinkdb\": \"^2.3.2\"\n  },\n  \"devDependencies\": {\n    \"jest-cli\": \"^13.2.3\"\n  }\n}\n<\/pre>\n<ol class=\"footnotes\"><li id=\"footnote_0_4730\" class=\"footnote\">https:\/\/facebook.github.io\/jest\/docs\/api.html#testpathdirs-array-string<span class=\"footnote-back-link-wrapper\"> [<a href=\"#identifier_0_4730\" class=\"footnote-link footnote-back-link\">&#8617;<\/a>]<\/span><\/li><\/ol>","protected":false},"excerpt":{"rendered":"<p>setting up where Jest looks for unit tests<\/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\/4730"}],"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=4730"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/4730\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=4730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=4730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=4730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}