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

TypeError: Cannot set property 'currentTest' of undefined #40

Open
jeremyhiggs opened this issue Nov 16, 2019 · 4 comments
Open

TypeError: Cannot set property 'currentTest' of undefined #40

jeremyhiggs opened this issue Nov 16, 2019 · 4 comments

Comments

@jeremyhiggs
Copy link

jeremyhiggs commented Nov 16, 2019

When running jest with jest-allure installed, I often receive the above error. This did not use to happen, before using jest-allure.

Extended error message:

UserPreferences › can create an instance of the model from an arbitrary mock

TypeError: Cannot set property 'currentTest' of undefined

  at Allure.Object.<anonymous>.Allure.startCase (node_modules/allure-js-commons/index.js:44:23)
  at JasmineAllureReporter.specStarted (node_modules/jest-allure/dist/setup.js:24:21)

Package versions:

"jest": "^24.9.0",
"jest-allure": "^0.1.1",

Jest config (in package.json):

  "jest": {
    "collectCoverage": true,
    "coverageDirectory": "coverage",
    "preset": "jest-expo",
    "reporters": [
      "default"
    ],
    "setupFilesAfterEnv": [
      "jest-allure/dist/setup"
    ]
  }

I added a few console logs in jest-aalure/dist/setup.js:

FAIL models/tests/UserPreferences.test.js (98.219s)
● Console

console.error node_modules/jest-allure/dist/setup.js:23
  specStarted = skip NeedMock dummy
console.error node_modules/jest-allure/dist/setup.js:14
  startSuite = UserPreferences
console.error node_modules/jest-allure/dist/setup.js:23
  specStarted = can create an instance of the model from an arbitrary mock

It seems that startSuite is being called after specStarted, which would explain why Allure.startCase cannot find the suite. Any idea why this would be happening?

@arunp-motorq
Copy link

Any update on this ? Am having the same issue

@Xotabu4
Copy link

Xotabu4 commented Aug 10, 2020

Having the same issue

That happens when you use some reporters methods in before/beforeAll hooks. Jest-allure considers test is not started, so nothing to attach to:

before(()=> {
    reporter.addAttachment(`attach name`, JSON.stringify({
                hello: "world"
            }, null, 2), 'application/json')
})

@Xotabu4
Copy link

Xotabu4 commented Aug 11, 2020

Same as #6

@ma-nk
Copy link

ma-nk commented Jan 30, 2023

For us the case was in an odd test which had no parent describe block. Wrapping it with one solved the issue

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

4 participants