Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "path" argument must be of type string. Received undefined for nx 14 - when running migration "update-jest-config-extensions" #10164

Closed
WtfJoke opened this issue May 5, 2022 · 6 comments · Fixed by #10180
Assignees
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug

Comments

@WtfJoke
Copy link

WtfJoke commented May 5, 2022

Current Behavior

We've upgraded from nx 13.10 to the latest available 14.1.1.
When we run the migration "update-jest-config-extensions" we received the error:
We figured out its caused when you have any configuration block inside the test-target.

Running migration update-jest-config-extensions
The "path" argument must be of type string. Received undefined

Expected Behavior

We expect the migrations to succeed.

Steps to Reproduce

I've reproduced the issue in a fork, see here of your nx examples.

  1. git clone git@github.com:WtfJoke/nx-examples.git
  2. git checkout jest-config-migration
  3. yarn install
  4. yarn nx migrate --run-migrations

Failure Logs

yarn run v1.22.18
$ nx migrate --run-migrations --verbose

>  NX  Running 'yarn' to make sure necessary packages are installed

[1/4] Resolving packages...
success Already up-to-date.
$ ngcc --properties es2015 browser module main && node decorate-angular-cli.js

 >  NX   Angular CLI has been decorated to enable computation caching.


>  NX  Running migrations from 'migrations.json'

Running migration 14-0-6-remove-root
Successfully finished 14-0-6-remove-root
---------------------------------------------------------
Running migration 14-0-0-change-nx-json-presets
Successfully finished 14-0-0-change-nx-json-presets
---------------------------------------------------------
Running migration 14-0-0-change-npm-script-executor
Successfully finished 14-0-0-change-npm-script-executor
---------------------------------------------------------
Running migration rename-module-federation-config
Successfully finished rename-module-federation-config
---------------------------------------------------------
Running migration update-jest-config-extensions
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:120:11)
    at extname (node:path:1386:5)
    at isJestConfigValid (/home/ryzen/dev/git/nx-examples/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js:37:42)
    at /home/ryzen/dev/git/nx-examples/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js:61:18
    at /home/ryzen/dev/git/nx-examples/node_modules/@nrwl/workspace/src/utilities/executor-options-utils.js:29:17
    at Array.forEach (<anonymous>)
    at forEachExecutorOptions (/home/ryzen/dev/git/nx-examples/node_modules/@nrwl/workspace/src/utilities/executor-options-utils.js:28:51)
    at /home/ryzen/dev/git/nx-examples/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js:59:61
    at Generator.next (<anonymous>)
Done in 19.32s.

Environment

   Node : 16.14.1
   OS   : linux x64
   yarn : 1.22.18

   nx : 14.1.1
   @nrwl/angular : 14.1.1
   @nrwl/cypress : 14.1.1
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.1.1
   @nrwl/eslint-plugin-nx : 14.1.1
   @nrwl/express : Not Found
   @nrwl/jest : 14.1.1
   @nrwl/js : 14.1.1
   @nrwl/linter : 14.1.1
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 14.0.3
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 14.1.1
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.1.1
   @nrwl/web : 14.1.1
   @nrwl/workspace : 14.1.1
   typescript : 4.6.3
   rxjs : 6.5.5
   ---------------------------------------
   Community plugins:
         @ngrx/component-store: 13.0.1
         @ngrx/effects: 13.0.1
         @ngrx/entity: 13.0.1
         @ngrx/router-store: 13.0.1
         @ngrx/store: 13.0.1
         @ngrx/store-devtools: 13.0.1

(node:30927) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /home/ryzen/dev/git/nx-examples/node_modules/tslib/package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)
Done in 1.05s.
@WtfJoke WtfJoke changed the title The "path" argument must be of type string. Received undefined - when running migration "update-jest-config-extensions" The "path" argument must be of type string. Received undefined for nx 14 - when running migration "update-jest-config-extensions" May 5, 2022
@AgentEnder AgentEnder added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label May 5, 2022
@barbados-clemens
Copy link
Contributor

can you run this migration with the --verbose flag so I can have a stack trace?

@WtfJoke
Copy link
Author

WtfJoke commented May 5, 2022

Sure, here is the stacktrace

yarn run v1.22.18
$ nx migrate --run-migrations --verbose

>  NX  Running 'yarn' to make sure necessary packages are installed

[1/4] Resolving packages...
success Already up-to-date.
$ ngcc --properties es2015 browser module main && node decorate-angular-cli.js

 >  NX   Angular CLI has been decorated to enable computation caching.


>  NX  Running migrations from 'migrations.json'

Running migration 14-0-6-remove-root
Successfully finished 14-0-6-remove-root
---------------------------------------------------------
Running migration 14-0-0-change-nx-json-presets
Successfully finished 14-0-0-change-nx-json-presets
---------------------------------------------------------
Running migration 14-0-0-change-npm-script-executor
Successfully finished 14-0-0-change-npm-script-executor
---------------------------------------------------------
Running migration rename-module-federation-config
Successfully finished rename-module-federation-config
---------------------------------------------------------
Running migration update-jest-config-extensions
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:120:11)
    at extname (node:path:1386:5)
    at isJestConfigValid (/home/ryzen/dev/git/nx-examples/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js:37:42)
    at /home/ryzen/dev/git/nx-examples/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js:61:18
    at /home/ryzen/dev/git/nx-examples/node_modules/@nrwl/workspace/src/utilities/executor-options-utils.js:29:17
    at Array.forEach (<anonymous>)
    at forEachExecutorOptions (/home/ryzen/dev/git/nx-examples/node_modules/@nrwl/workspace/src/utilities/executor-options-utils.js:28:51)
    at /home/ryzen/dev/git/nx-examples/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js:59:61
    at Generator.next (<anonymous>)
Done in 19.32s.

@fedelman
Copy link

fedelman commented May 6, 2022

I've got the same or at least a similar issue. Tried to migrate from 13.9.6 to 14.1.4 on MacOS 12.3.1.

nx migrate --run-migrations --verbose

NX Running 'yarn' to make sure necessary packages are installed

yarn install v1.22.18
[1/4] 🔍 Resolving packages...
success Already up-to-date.
✨ Done in 0.68s.

NX Running migrations from 'migrations.json'

Running migration 13-10-0-update-decorate-cli
Successfully finished 13-10-0-update-decorate-cli

Running migration 13-10-0-update-tasks-runner
Successfully finished 13-10-0-update-tasks-runner

Running migration 14-0-0-change-nx-json-presets
Successfully finished 14-0-0-change-nx-json-presets

Running migration 14-0-0-change-npm-script-executor
Successfully finished 14-0-0-change-npm-script-executor

Running migration 14-0-6-remove-root
Successfully finished 14-0-6-remove-root

Running migration update-jest-config-extensions
Cannot find module './jest.config'
Require stack:

  • /Users/falk/Code/porsche/slcheckout-nx/node_modules/@nrwl/jest/src/utils/config/functions.js
  • /Users/falk/Code/porsche/slcheckout-nx/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js
  • /private/var/folders/f9/z673qt556vg057b41864_n6m0000gn/T/tmp-26355-Kmvq9YpW51Wu/node_modules/nx/src/command-line/migrate.js
  • /private/var/folders/f9/z673qt556vg057b41864_n6m0000gn/T/tmp-26355-Kmvq9YpW51Wu/node_modules/nx/src/command-line/nx-commands.js
  • /private/var/folders/f9/z673qt556vg057b41864_n6m0000gn/T/tmp-26355-Kmvq9YpW51Wu/node_modules/nx/bin/init-local.js
  • /private/var/folders/f9/z673qt556vg057b41864_n6m0000gn/T/tmp-26355-Kmvq9YpW51Wu/node_modules/nx/bin/nx.js
    node:internal/modules/cjs/loader:936
    throw err;
    ^

Error: Cannot find module './jest.config'
Require stack:

  • /Users/falk/Code/porsche/slcheckout-nx/node_modules/@nrwl/jest/src/utils/config/functions.js
  • /Users/falk/Code/porsche/slcheckout-nx/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js
  • /private/var/folders/f9/z673qt556vg057b41864_n6m0000gn/T/tmp-26355-Kmvq9YpW51Wu/node_modules/nx/src/command-line/migrate.js
  • /private/var/folders/f9/z673qt556vg057b41864_n6m0000gn/T/tmp-26355-Kmvq9YpW51Wu/node_modules/nx/src/command-line/nx-commands.js
  • /private/var/folders/f9/z673qt556vg057b41864_n6m0000gn/T/tmp-26355-Kmvq9YpW51Wu/node_modules/nx/bin/init-local.js
  • /private/var/folders/f9/z673qt556vg057b41864_n6m0000gn/T/tmp-26355-Kmvq9YpW51Wu/node_modules/nx/bin/nx.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at evalmachine.:1:16
    at Script.runInContext (node:vm:139:12)
    at runInContext (node:vm:289:6)
    at jestConfigObject (/Users/falk/Code/porsche/slcheckout-nx/node_modules/@nrwl/jest/src/utils/config/functions.js:155:27)
    at updateJestPreset (/Users/falk/Code/porsche/slcheckout-nx/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js:14:56)
    at /Users/falk/Code/porsche/slcheckout-nx/node_modules/@nrwl/jest/src/migrations/update-14-0-0/update-jest-config-ext.js:64:13

@barbados-clemens
Copy link
Contributor

barbados-clemens commented May 6, 2022

@fedelman this should be fixed in #10035

what is happening is an error not being able use runInContext because the context doesn't include the relative path imports.
I'm hoping to get that PR merged here soon.

@barbados-clemens
Copy link
Contributor

for the @WtfJoke it looks like the migratory wasn't able to locate the defined jest config for your project.

so make sure the @nrwl/jest:jest exector options point to the correct jest config. what I gather is this is the line where it's breaking

https://github.com/nrwl/nx/blob/master/packages/jest/src/migrations/update-14-0-0/update-jest-config-ext.ts#L68

  const configExt = extname(options.jestConfig);

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug
Projects
None yet
4 participants