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

Not finding modules when running tests: #175

Closed
ssoworld opened this issue Mar 24, 2023 · 2 comments
Closed

Not finding modules when running tests: #175

ssoworld opened this issue Mar 24, 2023 · 2 comments

Comments

@ssoworld
Copy link

ssoworld commented Mar 24, 2023

unit testing a Yeoman generator has consistently failed to execute. Here are error messages using various test runs:

Mocha:

    at new NodeError (internal/errors.js:322:7)
    at throwExportsNotFound (internal/modules/esm/resolve.js:332:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:523:7)
    at resolveExports (internal/modules/cjs/loader.js:450:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    ... <local test call>

Jest

    Cannot find module 'yeoman-test' from '__tests__/app.test.ts' // arbitrary location

      1 | import path from 'path';
      2 | import assert from 'yeoman-assert';
    > 3 | import helpers from 'yeoman-test';
        | ^
      4 |
      5 | describe('<generator>:app', () => {
      6 |    beforeAll(() => {

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.<anonymous> (__tests__/app.test.ts:3:1)

I've seen multiple generators failing because of this.

@mshima
Copy link
Member

mshima commented Mar 24, 2023

Probably duplicate of #164 (comment).
yeoman-test is pure esm now.

@ssoworld
Copy link
Author

Closing for duplication reasons.

We should consider backward-compatibility and not have to force users to move to ECMA. Companies using this have to seriously consider the consequences of not unit testing their generators and having to rely on older versions while maintaining their generators. Sure, reverting to 6 is OK, but when one runs npm outdated or has Renovate (or equivalent) automating their updates, they have to take steps to disable this. Let's make it simple.

@ssoworld ssoworld closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2023
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