diff --git a/lib/utils.js b/lib/utils.js index 31904cc9e..52b1d088e 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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, "'") diff --git a/test/unit/plugin/screenshotOnFail_test.js b/test/unit/plugin/screenshotOnFail_test.js index aac10ec8a..7105cfaa2 100644 --- a/test/unit/plugin/screenshotOnFail_test.js +++ b/test/unit/plugin/screenshotOnFail_test.js @@ -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"}' }); @@ -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 });