Skip to content

Commit

Permalink
fix: make test.id looks like a property
Browse files Browse the repository at this point in the history
  • Loading branch information
j0tunn committed Jul 25, 2019
1 parent 6836147 commit 9964432
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/test-reader/mocha-test-parser.js
Expand Up @@ -85,14 +85,18 @@ module.exports = class MochaTestParser extends EventEmitter {
});

this.on(ParserEvents.SUITE, (suite) => {
suite._id = `${getShortMD5(filePath)}${suiteCounter++}`;
suite.id = () => suite._id;
const id = `${getShortMD5(filePath)}${suiteCounter++}`;
suite.id = () => id;
suite.id.toString = () => id;
});
}

_extendTestApi() {
this.on(ParserEvents.TEST, (test) => {
test.id = () => getShortMD5(test.fullTitle());
const id = getShortMD5(test.fullTitle());
test.id = () => id;
test.id.toString = () => id;

test.browserId = this._browserId;
});
}
Expand Down
4 changes: 4 additions & 0 deletions test/lib/test-reader/mocha-test-parser.js
Expand Up @@ -331,6 +331,9 @@ describe('test-reader/mocha-test-parser', () => {

assert.equal(suite1.id(), '123450');
assert.equal(suite2.id(), '123451');

assert.equal(suite1.id, '123450');
assert.equal(suite2.id, '123451');
});

it('"id" getter results should not be dependent on suite parsing order', () => {
Expand Down Expand Up @@ -441,6 +444,7 @@ describe('test-reader/mocha-test-parser', () => {
const test = MochaStub.lastInstance.suite.tests[0];

assert.equal(test.id(), '12345');
assert.equal(test.id, '12345');
});

it('shold set browserId property to test', () => {
Expand Down

0 comments on commit 9964432

Please sign in to comment.