Ensure that test titles are strings before sanitizing them for screenshot names (#4317)

* Ensure that test titles are strings before sanitizing them for screenshot names

* Fix linting errors

* stringify non-string title, return '' for null and undefined

* minor cleanup. extract to outer function. refactor to lodash.


Co-authored-by: Brian Mann <brian.mann86@gmail.com>
This commit is contained in:
Jennifer Shehane
2019-06-12 23:44:32 +06:30
committed by Brian Mann
parent 546c92e1fc
commit 4bd3cf2c53
3 changed files with 38 additions and 3 deletions
+5 -2
View File
@@ -1,7 +1,7 @@
require('../spec_helper')
const la = require('lazy-ass')
const {stripIndent, stripIndents} = require('common-tags')
const { stripIndent, stripIndents } = require('common-tags')
const snapshot = require('../support/snapshot')
describe('stripIndent', () => {
@@ -12,6 +12,7 @@ describe('stripIndent', () => {
third line
last line
`
// should preserve the structure of the text
snapshot(removed)
})
@@ -21,7 +22,8 @@ describe('stripIndent', () => {
const removed = stripIndent(text)
// removed 1 level of indentation and trimmed the string
const expected = 'foo\n bar'
la(removed === expected, 'removed indent is\n' + removed)
la(removed === expected, `removed indent is\n${removed}`)
})
it('can be used with nested message', () => {
@@ -33,6 +35,7 @@ describe('stripIndent', () => {
last line
`
// should have NO indents
// first line
//