Skip to content

Commit

Permalink
fix(utils): remove . of test title to avoid confusion (#3431)
Browse files Browse the repository at this point in the history
* fix(utils): remove . of test title to avoid confusion

* remove . at the end of test title
  • Loading branch information
kobenguyent committed Oct 5, 2022
1 parent 7b1d48d commit 0d653cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/utils.js
Expand Up @@ -132,6 +132,9 @@ module.exports.clearString = function (str) {
if (!str) return '';
/* Replace forbidden symbols in string
*/
if (str.endsWith('.')) {
str = str.slice(0, -1);
}
return str
.replace(/ /g, '_')
.replace(/"/g, "'")
Expand Down
9 changes: 8 additions & 1 deletion test/unit/plugin/screenshotOnFail_test.js
Expand Up @@ -20,6 +20,14 @@ describe('screenshotOnFail', () => {
});
});

it('should remove the . at the end of test title', async () => {
screenshotOnFail({});
event.dispatcher.emit(event.test.failed, { title: 'test title.' });
await recorder.promise();
expect(screenshotSaved.called).is.ok;
expect('test_title.failed.png').is.equal(screenshotSaved.getCall(0).args[0]);
});

it('should exclude the data driven in failed screenshot file name', async () => {
screenshotOnFail({});
event.dispatcher.emit(event.test.failed, { title: 'Scenario with data driven | {"login":"admin","password":"123456"}' });
Expand Down Expand Up @@ -53,6 +61,5 @@ describe('screenshotOnFail', () => {
const regexpFileName = /test1_[0-9]{10}.failed.png/;
expect(fileName.match(regexpFileName).length).is.equal(1);
});

// TODO: write more tests for different options
});

0 comments on commit 0d653cd

Please sign in to comment.