Testdeck Version
0.0.6
Testdeck Package
NodeJS Version
Mocha / Jasmine / Jest Version
- Mocha: 6.1.4
@types/mocha: 5.2.6
Operating System
Actual Behaviour
Consider the following test:
import { suite, test } from "@testdeck/mocha";
[{ title: 'world'}, { title: 'github'}]
.forEach(({title}) => {
@suite(`Hello ${title}`)
class Hello {
constructor() {
console.log('');
console.log(`Hello ${title}`);
}
@test
test1() {
console.log('test1');
}
@test
test2() {
console.log('test2');
}
}
});
Hello class is instantiated 4 times, i.e. once per test
Hello world
test1
Hello world
test2
Hello github
test1
Hello github
test2
Expected Behaviour
Only 2 Hello class instances should have been created
Hello world
test1
test2
Hello github
test1
test2
Additional Information
Official documentation Instance Lifecycle Hooks is providing the impression that @suite class may have an internal state, which is clearly not true.
Please note, that suite scope state can only be achieved via class instance or actual mocha suite. IMHO it's a bad practice to pollute mocha suite context.
Testdeck Version
0.0.6
Testdeck Package
@testdeck/core@testdeck/mochaNodeJS Version
Mocha / Jasmine / Jest Version
@types/mocha: 5.2.6Operating System
Actual Behaviour
Consider the following test:
Hello class is instantiated 4 times, i.e. once per test
Expected Behaviour
Only 2 Hello class instances should have been created
Additional Information
Official documentation Instance Lifecycle Hooks is providing the impression that
@suite classmay have an internal state, which is clearly not true.Please note, that suite scope state can only be achieved via class instance or actual mocha suite. IMHO it's a bad practice to pollute mocha suite context.