You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, in my case version is gotten from an async call - which I tried to put in before. However, it looks like the "it" test is done before before returns .
describe('some test suite', function () {
let response;
before('precondition', async function () {
response = await getHttpResponse(); //some async http get req which returns {status: true, data: ...}
});
(response.status ? it : it.skip)('test', async function () {
// do the test
});
});
I get the error TypeError: Cannot read property 'status' of undefined because response is undefined ;)
How does the block initialization happen and how can I solve it? I see that for example the status in my precondition is equal true, but the test is initialized with response === undefined
I saw a similar question years ago, but could not find a solution: #591 (comment)
The text was updated successfully, but these errors were encountered:
Mocha runs in several cycles. In one (synchronous) phase the test file is parsed and the test hierarchy built. In a later phase the test and hooks are executed. Note that the descibe block is always synchronous, tests and hooks can be both sync/async.
Please see our docs, especially ["When a test file is loaded, Mocha executes all of its suites and finds – but does not execute – any hooks and tests therein."]
For dynamically skipping test at runtime, use this.skip() instead.
However, in my case version is gotten from an async call - which I tried to put in before. However, it looks like the "it" test is done before before returns .
I get the error TypeError: Cannot read property 'status' of undefined because response is undefined ;)
How does the block initialization happen and how can I solve it? I see that for example the status in my precondition is equal
true
, but the test is initialized with response ===undefined
I saw a similar question years ago, but could not find a solution:
#591 (comment)
The text was updated successfully, but these errors were encountered: