allure-mocha - TypeError: Cannot read property 'epic' of undefined
See original GitHub issueI’m trying to do this configuration, but allure is undefined. Do you have any example calling allure method from mocha tests using TypeScript?
"allure-mocha": "2.0.0-beta.6",
// es-modules
import { allure } from 'allure-mocha/runtime';
// or commonjs
const { allure } = require('allure-mocha/runtime');
it('is a test', () => {
allure.epic('Some info');
});
TypeError: Cannot read property 'epic' of undefined
Thank you
Issue Analytics
- State:
- Created 4 years ago
- Reactions:26
- Comments:33 (11 by maintainers)
Top Results From Across the Web
Cannot read property 'Base' of undefined error using mocha ...
I was able to use mocha-allure-reporter by simply installing it (along with mocha), npm install mocha mocha-allure-reporter.
Read more >allure-framework/allure-core - Gitter
TypeError : Cannot read property 'createAttachment' of undefined and allure methods like createStep, attachment and other (critical); run in parallel (not ...
Read more >allure-decorators - npm
This project introduces TS decorators integration for Allure framework. Installation based on allure-mocha reporter. npm i allure-js-commons allure-decorators ...
Read more >typeerror can not read property x of null - YouTube
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >ANGULAR 13 TypeError Cannot read property of undefined
In this tutorial, we will see a most common error faced by the Angular developers named as " TypeError Cannot read property of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should work as soon as #138 is merged and a new version is released. I’ve added epic tests and tested it locally with decorators as well. So stay tuned.
@fescobar @tims-j is there any reason you can’t use es6 import syntax?
The problem here is in a combination of Mocha specifics and plain-old JS
require
syntax.First of all, we have to use default export for reporter itself to be able to include it via -R option. On the other hand, we can’t make
allure
default as well, asallure-runtime
makes 3 exports.So what’s wrong with
require
syntax then? Nothing special, except the fact that when you destructureallure
viarequire
, it detaches it from the reporter context.The problem here is that this variable’s value is populated in runtime, when AllureReport is initialized by Mocha. So when you detached it via
require
you couldn’t track any changes anymore. That’s why you gotepic of undefined
error. However, it would fail the same way for any other property as well.You may wonder how to fix that? Either use es6 import syntax, which correctly handles destructuring without detaching object from its parent context, or operate with a root runtime object. But in the latter case you can access
allure
only within test.