File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
packages/expect-puppeteer/src Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,18 @@ if (typeof global.expect !== 'undefined') {
88
88
const originalExpect = global . expect
89
89
global . expect = ( actual , ...args ) => {
90
90
const type = getPuppeteerType ( actual )
91
- if ( type ) return expectPuppeteer ( actual )
91
+ if ( type ) {
92
+ const matchers = expectPuppeteer ( actual )
93
+ const jestMatchers = originalExpect ( actual , ...args )
94
+ return {
95
+ ...jestMatchers ,
96
+ ...matchers ,
97
+ not : {
98
+ ...jestMatchers . not ,
99
+ ...matchers . not ,
100
+ } ,
101
+ }
102
+ }
92
103
return originalExpect ( actual , ...args )
93
104
}
94
105
Object . keys ( originalExpect ) . forEach ( prop => {
Original file line number Diff line number Diff line change
1
+ describe ( 'expect-puppeteer' , ( ) => {
2
+ beforeEach ( async ( ) => {
3
+ await page . goto ( 'http://localhost:4444' )
4
+ } )
5
+
6
+ it ( 'should work with original Jest matchers' , async ( ) => {
7
+ expect ( page ) . toBeDefined ( )
8
+ expect ( page ) . not . toBe ( null )
9
+
10
+ const main = await page . $ ( 'main' )
11
+ expect ( main ) . toBeDefined ( )
12
+ expect ( main ) . not . toBe ( null )
13
+ } )
14
+ } )
You can’t perform that action at this time.
0 commit comments