Preset ts-jest is invalid: The "id" argument must be of type string. Received null
See original GitHub issue🐛 Bug Report
To Reproduce
Steps to reproduce the behavior:
I use AWS CodeBuild to deploy a project and I invoke jest tests during the deployment. When the NODE_ENV is set to dev, there is no problem, but when NODE_ENV is set to production. I get the following error:
[Container] 2020/05/13 16:48:41 Running command npx jest -i src/spec/
--
142 | npx: installed 503 in 12.817s
143 | ● Validation Error:
144 |
145 | Preset ts-jest is invalid:
146 |
147 | The "id" argument must be of type string. Received null
148 | TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received null
149 | at validateString (internal/validators.js:117:11)
150 | at Module.require (internal/modules/cjs/loader.js:1037:3)
151 | at require (internal/modules/cjs/helpers.js:77:18)
152 | at setupPreset (/root/.npm/_npx/312/lib/node_modules/jest/node_modules/jest-config/build/normalize.js:289:14)
153 | at normalize (/root/.npm/_npx/312/lib/node_modules/jest/node_modules/jest-config/build/normalize.js:642:15)
154 | at readConfig (/root/.npm/_npx/312/lib/node_modules/jest/node_modules/jest-config/build/index.js:220:68)
155 | at async readConfigs (/root/.npm/_npx/312/lib/node_modules/jest/node_modules/jest-config/build/index.js:400:26)
156 | at async runCLI (/root/.npm/_npx/312/lib/node_modules/jest/node_modules/@jest/core/build/cli/index.js:198:59)
157 | at async Object.run (/root/.npm/_npx/312/lib/node_modules/jest/node_modules/jest-cli/build/cli/index.js:163:37)
I actually do have ts-jest installed and during the deployment I install the following as dev dependencies:
- npm install i -D jest @types/jest ts-jest
I can confirm that ts-jest is installed during the deployment:
[Container] 2020/05/13 16:48:40 Running command npx ts-jest
--
128 | npx: installed 19 in 1.403s
129 |
130 | Usage:
131 | ts-jest command [options] [...args]
132 |
133 | Commands:
134 | config:init Creates initial Jest configuration
135 | config:migrate Migrates a given Jest configuration
136 | help [command] Show this help, or help about a command
137 |
138 | Example:
139 | ts-jest help config:migrate
If it was not installed, I would have gotten a ts-jest error above.
However, the next line contains this:
- npx jest -i src/spec/
And this when the error happens. When NODE_ENV is set to production in the container, Jest seems to ignore the dev dependencies installed. This is wrong because I don’t want to put jest and ts-jest into dependencies during my production deploy.
How am i able to address the problem?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:11
Top GitHub Comments
I just ran
npm i --save-dev ts-jest
againdev deps are not installed if
NODE_ENV
isproduction
, see https://docs.npmjs.com/cli/install.No idea if that’s the issue here (I’ve never used, or heard of, AWS CodeBuild). If you think this is a bug with Jest, pleas open up a new issue with full reproduction steps, following the template