question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:11

github_iconTop GitHub Comments

23reactions
Robbie-Cookcommented, Jun 19, 2020

I just ran npm i --save-dev ts-jest again

4reactions
SimenBcommented, May 27, 2020

dev deps are not installed if NODE_ENV is production, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

The "id" argument must be of type string. Received type object
As I created my first app and run, I got this error. TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received...
Read more >
err! typeerror [err_invalid_arg_type]: the "id" argument must be ...
ERR! TypeError: The "id" argument must be of type string. Received an instance of Object ERR! at new NodeError (node:internal/errors:371:5) .
Read more >
Configuring Jest
The Jest philosophy is to work great by default, but sometimes you just need more configuration power.
Read more >
rushstack/rushstack - Gitter
Validation Error: Preset ./node_modules/@rushstack/heft/includes/jest-shared.config.json is invalid: The "id" argument must be of type string. Received null ...
Read more >
Troubleshooting | jest-preset-angular - GitHub Pages
You can check Jest troubleshooting guide. ... you can install core-js and import the reflection library in your setup-jest.ts :.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found