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

Failed to load reporter module jasmine 4.x #189

Closed
ffortier opened this issue Jan 6, 2022 · 1 comment · Fixed by #190
Closed

Failed to load reporter module jasmine 4.x #189

ffortier opened this issue Jan 6, 2022 · 1 comment · Fixed by #190

Comments

@ffortier
Copy link
Contributor

ffortier commented Jan 6, 2022

Hello, since the major release to jasmine 4.0.1, the following code described in the documentation fails with the this error

Error: Failed to load reporter module jasmine-ts-console-reporter
Underlying error: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '$PROJECT/jasmine-ts-console-reporter' imported from '$PROJECT/node_modules/jasmine/lib/loader.js'
npm i --save-dev jasmine-ts-console-reporter
npx jasmine --reporter=jasmine-ts-console-reporter

It seems to be caused by this line

https://github.com/jasmine/jasmine-npm/blob/main/lib/command.js#L169

async function registerReporter(reporterModuleName, jasmine) {
  let Reporter;

  try {
    Reporter = await new Loader().load(resolveReporter(reporterModuleName));
  } catch (e) {
    throw new Error('Failed to load reporter module '+ reporterModuleName +
      '\nUnderlying error: ' + e.stack + '\n(end underlying error)');
  }

I believe that the code should use the jasmine.loader instead of creating a new Loader() so that we can set the jsLoader: 'require' in a config file when necessary. So something like this

async function registerReporter(reporterModuleName, jasmine) {
  let Reporter;

  try {
    Reporter = await jasmine.loader.load(resolveReporter(reporterModuleName));
  } catch (e) {
    throw new Error('Failed to load reporter module '+ reporterModuleName +
      '\nUnderlying error: ' + e.stack + '\n(end underlying error)');
  }
@sgravrock
Copy link
Member

I'm hoping to get this released today. I just have a bit more testing to do first.

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

Successfully merging a pull request may close this issue.

2 participants