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

does not work with nrwl nx #42

Closed
alfredoperez opened this issue Sep 4, 2020 · 1 comment
Closed

does not work with nrwl nx #42

alfredoperez opened this issue Sep 4, 2020 · 1 comment

Comments

@alfredoperez
Copy link

I tried to generate a test in a project that uses nrwl and is not able to find modules

Error: Cannot find module '@scwx/utils-alerts'
Require stack:
- 
- /usr/local/lib/node_modules/ngentest/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
    at Function.Module._load (internal/modules/cjs/loader.js:923:27)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (<anonymous>:13:24)
    at Module._compile (internal/modules/cjs/loader.js:1251:30)
    at requireFromString (/usr/local/lib/node_modules/ngentest/node_modules/require-from-string/index.js:28:4)
    at run (/usr/local/lib/node_modules/ngentest/index.js:151:21)
    at Object.<anonymous> (/usr/local/lib/node_modules/ngentest/index.js:220:3)
    at Module._compile (internal/modules/cjs/loader.js:1251:30) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '', '/usr/local/lib/node_modules/ngentest/index.js' ]
}
@allenhwkim
Copy link
Owner

allenhwkim commented Sep 8, 2020

Hi

This happens when the test generator, which has an isolated environment, tries to compile your code. Which means it can't find your module.

As you seen in README.md, try using replacements.
This does not mean replacing your code. It just temporarily replace the code in memory.

replacements: There are some codes, which causes error without proper environment. You need to replace these codes. You can specify from value with regular expression and to value with string. e.g.

replacements: [
  { from: '^\\S+\\.define\\(.*\\);', to: ''}`
]

For example,

  // faking import for errorenous lib.
  replacements: [
    { from: '@scwx\\/utils-alerts, to: '@angular/core' }
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants