File tree 3 files changed +24
-11
lines changed
3 files changed +24
-11
lines changed Original file line number Diff line number Diff line change 3
3
exports [` lib/extend.ts should handle the LabelText methods 1` ] = ` "<input id =\\"label-text-input\\" type =\\"text\\">"`;
4
4
5
5
exports[`lib/extend.ts should handle the get* method failures 1`] = `
6
- " TestingLibraryElementError: Unable to find an element with the title: missing.
6
+ TestingLibraryElementError: Unable to find an element with the title: missing.
7
7
8
8
<div
9
- id=\\ " scoped\\ "
9
+ id = " scoped"
10
10
>
11
11
12
12
@@ -16,7 +16,7 @@ exports[`lib/extend.ts should handle the get* method failures 1`] = `
16
16
17
17
18
18
</div >
19
- <stack >:X:X"
19
+ <stack >:X:X
20
20
`;
21
21
22
22
exports[`lib/extend.ts should handle the get* methods 1`] = `"<input type =\\"text\\" data-testid =\\"testid-text-input\\">"`;
Original file line number Diff line number Diff line change 1
1
import * as path from 'path'
2
2
import * as playwright from 'playwright'
3
3
4
+ import stacktraceSerializer from './serializers/stacktrace'
5
+
6
+ expect . addSnapshotSerializer ( stacktraceSerializer )
7
+
4
8
describe ( 'lib/extend.ts' , ( ) => {
5
9
let browser : playwright . ChromiumBrowser
6
10
let page : playwright . Page
@@ -52,14 +56,7 @@ describe('lib/extend.ts', () => {
52
56
// Use the scoped element so the pretty HTML snapshot is smaller
53
57
const scope = await document . $ ( '#scoped' )
54
58
55
- try {
56
- await scope ! . getByTitle ( 'missing' )
57
- fail ( ) // eslint-disable-line jest/no-jasmine-globals
58
- } catch ( err ) {
59
- err . message = err . message . replace ( / ( \s * a t .* ( \n | $ ) ) + / gm, '\n <stack>:X:X' )
60
- // eslint-disable-next-line jest/no-try-expect
61
- expect ( err . message ) . toMatchSnapshot ( )
62
- }
59
+ await expect ( async ( ) => scope ! . getByTitle ( 'missing' ) ) . rejects . toThrowErrorMatchingSnapshot ( )
63
60
} )
64
61
65
62
it ( 'should handle the LabelText methods' , async ( ) => {
Original file line number Diff line number Diff line change
1
+ type Serializer = Parameters < typeof expect . addSnapshotSerializer > [ '0' ]
2
+
3
+ const EXPRESSION = / ( \s * a t .* ( \n | $ ) ) + / gm
4
+ const PLACEHOLDER = '\n <stack>:X:X'
5
+
6
+ const serializer : Serializer = {
7
+ serialize ( val ) {
8
+ return typeof val === 'string' ? val . replace ( EXPRESSION , PLACEHOLDER ) : val
9
+ } ,
10
+
11
+ test ( val ) {
12
+ return typeof val === 'string' && EXPRESSION . test ( val )
13
+ } ,
14
+ }
15
+
16
+ export default serializer
You can’t perform that action at this time.
0 commit comments