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

jasmine is not defined error coming up when we try to run script #8

Open
vjuturu opened this issue Dec 12, 2018 · 17 comments
Open

jasmine is not defined error coming up when we try to run script #8

vjuturu opened this issue Dec 12, 2018 · 17 comments
Labels
question Further information is requested

Comments

@vjuturu
Copy link

vjuturu commented Dec 12, 2018

ReferenceError: jasmine is not defined
at registerAllureReporter (/Users/xxxx/Projects/xxxx/xxxx/node_modules/jest-allure/dist/setup.js:46:5)

Steps followed:

  1. "jest": { "setupTestFrameworkScriptFile": "./func-test-jest.config.js" },
  2. just imported in global setup file const { registerAllureReporter } = require("jest-allure/dist/setup");

please advise.

Thanks
--vj

@theasc
Copy link

theasc commented Jan 11, 2019

I have the same problem. Any solution to it?

@zaqqaz
Copy link
Owner

zaqqaz commented Mar 1, 2019

Don't faced with such error yet.
Could you provide more information ? (better link to demo project somewhere on github).

Btw, here is demo project with jest-alure integration https://github.com/zaqqaz/visual-unit-tests/blob/master/src/setupTests.ts

just clone it and try it yourself.

@zaqqaz zaqqaz added the question Further information is requested label Mar 1, 2019
@akaguny
Copy link

akaguny commented Apr 16, 2019

Show your version of jest @vjuturu.
And try to add something as setupFilesAfterEnv: ["jest-allure/dist/setup"] in your jest.config.js;
Now i will check compatibility jest-allure with the latest jest and will try to get PR because i think that jest-allure not up to date

@akaguny
Copy link

akaguny commented Apr 23, 2019

resolved in #15

@kevinoliveira
Copy link

kevinoliveira commented Jun 3, 2019

Versions
"jest": "^24.8.0",
"jest-allure": "^0.1.1",

jest.config.js

module.exports = {
    reporters: ["default", "jest-allure","jest-stare"],
    setupFilesAfterEnv: ["jest-allure/dist/setup"]
};
FAIL  src/home/example.test.ts
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at node_modules/@jest/core/build/TestScheduler.js:242:24
      at asyncGeneratorStep (node_modules/@jest/core/build/TestScheduler.js:131:24)
      at _next (node_modules/@jest/core/build/TestScheduler.js:151:9)
      at node_modules/@jest/core/build/TestScheduler.js:156:7
      at node_modules/@jest/core/build/TestScheduler.js:148:12
      at onResult (node_modules/@jest/core/build/TestScheduler.js:271:25)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.329s
Ran all test suites.

I have tests, those are the results if i remove setupFilesAfterEnv from jest config file

 PASS  src/home/example.test.ts
  ✓ example testing (3ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.354s
Ran all test suites.

@zaqqaz
Copy link
Owner

zaqqaz commented Jun 4, 2019

@kevinoliveira can you attach the source of src/home/example.test.ts?

@kevinoliveira
Copy link

src/home/example.ts

const example = ()=>"this is a example!";

export {example}

src/home/example.test.ts

import { example} from "./example";

test(
"example testing",
() => expect(example()).toBe("this is a example!")
);

@cinderblock
Copy link

cinderblock commented Jan 5, 2020

I am also getting error:

  ● Test suite failed to run

    ReferenceError: jasmine is not defined

      at registerAllureReporter (node_modules/jest-allure/dist/setup.js:46:5)
      at Object.<anonymous> (node_modules/jest-allure/dist/setup.js:49:1)
          at Array.forEach (<anonymous>)

jest.config.js

  ...
  setupFilesAfterEnv: ['jest-allure/dist/setup'],
  reporters: [
    'default',
    'jest-github-reporter',
    ...

package.json

  ...
  "devDependencies": {
    "jasmine": "^3.5.0",
    "jest-allure": "^0.1.1",
    ...
  }

tests/main.ts

import { wait } from '../src/wait';
import process from 'process';
import cp from 'child_process';
import path from 'path';

test('throws invalid number', async () => {
  const input = parseInt('foo', 10);
  await expect(wait(input)).rejects.toThrow('milliseconds not a number');
});

test('wait 500 ms', async () => {
  const start = new Date();
  await wait(500);
  const end = new Date();
  const delta = Math.abs(end.getTime() - start.getTime());
  expect(delta).toBeGreaterThan(450);
});

// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
  process.env['INPUT_MILLISECONDS'] = '500';
  const ip = path.join(__dirname, '..', 'lib', 'main.js');
  const options: cp.ExecSyncOptions = {
    env: process.env,
  };
  console.log(cp.execSync(`node ${ip}`, options).toString());
});

EDIT:

Looks like it's because of testRunner: 'jest-circus/runner'


EDIT2:

@kevinoliveira Looks like I'm actually having the same problem (which is I think different that this one) over in #43.

@SandyLQ
Copy link

SandyLQ commented Feb 24, 2020

@kevinoliveira Hello, I have the same issue as you had, I am curious if you solved it?
I am using jest 25.1.0

@YuriiSmal
Copy link

@kevinoliveira Hello, I have the same issue as you had, I am curious if you solved it?

Hi, I had the same situation and found no one answer wich worked for me.
Now I using another way. I added this row for jest.config.js
testRunner : 'jasmine2'

it's resolve issue with
ReferenceError: jasmine is not defined
at registerAllureReporter

and report generate successed

@kevinoliveira
Copy link

kevinoliveira commented Jul 21, 2020

Awesome news, I will take a look on the next few days!

@zaqqaz
Copy link
Owner

zaqqaz commented Jun 11, 2021

Yep, that's the correct solution.
https://github.com/zaqqaz/jest-allure#uses-jest-circus-or-jest--v-27-

@character123
Copy link

@kevinoliveira Hello, I have the same issue as you had, I am curious if you solved it?

Hi, I had the same situation and found no one answer wich worked for me.
Now I using another way. I added this row for jest.config.js
testRunner : 'jasmine2'

it's resolve issue with
ReferenceError: jasmine is not defined
at registerAllureReporter

and report generate successed

Thanks! It works for me

@jbricenoz
Copy link

Hi! I was able to fix the issue using:

testRunner : 'jasmine2',

into the jest config file:

module.exports = {
    verbose: true,
    preset: 'jest-playwright-preset',
    testRunner : 'jasmine2',
    transform:{
        "^.+\\.tsx?$": "ts-jest",
    },
    testTimeout: 120000,
    reporters: ["default", "jest-allure"],
    moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
    setupFilesAfterEnv: ['jest-allure/dist/setup','expect-playwright'],
    testMatch: [
        "**/tests/**/*.spec.(js|jsx|ts|tsx)",
        // "**/tests/**/*.test.(js|jsx|ts|tsx)"
    ]
};

@pedronastasi
Copy link

pedronastasi commented Oct 17, 2022

I'm using Jest 27 and testRunner : 'jasmine2' didn't work for me

Instead I added this to my package.json and worked:

 "jest": {
    "testRunner": "jest-jasmine2"
  }

@saritvakrat
Copy link

I have Jest 29, adding, I tried several solutions, still does not work

@hoa-pham82
Copy link

hoa-pham82 commented Oct 7, 2023

I have Jest 29, adding, I tried several solutions, still does not work

@saritvakrat Try to install this package: jest-jasmine2 and set it to the file jest.config.js: testRunner: "jest-jasmine2"

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

No branches or pull requests