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

"ReferenceError: jasmine is not defined" when following instructions to use allure-js with Jest #447

Closed
jamesmortensen opened this issue May 31, 2022 · 3 comments

Comments

@jamesmortensen
Copy link

Describe the bug
After following the instructions to use allure-js with Jest, I get the following error message when trying to run jest:

ReferenceError: jasmine is not defined

       8 |   resultsDir: "./allure-results"
       9 | }));
    > 10 | jasmine.getEnv().addReporter(reporter);
         | ^
      11 | //export default JasmineAllureReporter;

      at allure-report.mjs:10:1
      at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:317:13)
      at runJest (node_modules/@jest/core/build/runJest.js:407:19)

It says jasmine is not defined. I did attempt to instantiate jasmine with:

const Jasmine = require('jasmine');
const jasmine = new Jasmine().jasmine;

But then the test runner is not able to find any of the tests in the spec files.

To Reproduce
Steps to reproduce the behavior:

  1. Create allure-results.js or allure-results.mjs and copy the code from the instructions here on the allure jest README
  2. Be sure to add the setupFilesAfterEnv: ["<rootDir>/path/to/allure-report.js"] to the jest.config.js file.
  3. Attempt to run the tests with NODE_OPTIONS=--experimental-vm-modules npx jest
  4. See error above. Note that it works without the reporter.

Expected behavior
I expected the tests to run and for an allure-results folder to be generated with test results. Instead, we get the error that jasmine is not found or in cases where I tried to load jasmine, no tests found.

Desktop (please complete the following information):

  • OS: macOS 12.3.1 Mac M1
  • Browser: N/A
  • Version: N/A
  • Node.js version 14.17.5
@jamesmortensen
Copy link
Author

I discovered folks having the same error in another jest reporter package, zaqqaz/jest-allure#8 (comment) and they said the test runner was the problem. I changed to jasmine2 as suggested in the comments, and then the report generated.

But from what I can tell, the setup in your README for allure-js for Jest doesn't seem to be using allure-js at all. According to the README, I had to install allure-jasmine and allure-js-commons, and I've observed I'm able to remove allure-js and the report still generates. Is allure-js involved in this at all, or is this project just showing instructions to configure the allure reporter for other npm modules which are deprecated?

I also discovered the report left out a lot of failed suites due to execution errors in the tests. I'm not sure if I'm using the right reporter or an outdated one, and I don't want to setup a new project with deprecated tech. I can see in the allure-framework GitHub organization that allure-jasmine is deprecated, but the instructions in the README say to import allure-jasmine.

I'll wait for an update from you, and then I'll give it a try again. Please let me know if you need any more clarifiction. Thank you.

@baev
Copy link
Member

baev commented Aug 8, 2022

a while ago ( https://jestjs.io/blog/2021/05/25/jest-27 ) Jest switched the defaults and now uses circus instead of jasmine as a test runner. So far Allure officially only supports Jasmine test runner.

We expect official support for circus runner to be landed later this year (our team already selected it for dev, issue #282)

So at the moment there are 2 options available:

@baev baev closed this as completed Aug 8, 2022
@baev
Copy link
Member

baev commented Aug 8, 2022

Duplicate of #282

@baev baev marked this as a duplicate of #282 Aug 8, 2022
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