diff --git a/packages/expect-puppeteer/src/index.js b/packages/expect-puppeteer/src/index.js index 5776f6ac..b2294400 100644 --- a/packages/expect-puppeteer/src/index.js +++ b/packages/expect-puppeteer/src/index.js @@ -88,7 +88,18 @@ if (typeof global.expect !== 'undefined') { const originalExpect = global.expect global.expect = (actual, ...args) => { const type = getPuppeteerType(actual) - if (type) return expectPuppeteer(actual) + if (type) { + const matchers = expectPuppeteer(actual) + const jestMatchers = originalExpect(actual, ...args) + return { + ...jestMatchers, + ...matchers, + not: { + ...jestMatchers.not, + ...matchers.not, + }, + } + } return originalExpect(actual, ...args) } Object.keys(originalExpect).forEach(prop => { diff --git a/packages/expect-puppeteer/src/index.test.js b/packages/expect-puppeteer/src/index.test.js new file mode 100644 index 00000000..78cf6236 --- /dev/null +++ b/packages/expect-puppeteer/src/index.test.js @@ -0,0 +1,14 @@ +describe('expect-puppeteer', () => { + beforeEach(async () => { + await page.goto('http://localhost:4444') + }) + + it('should work with original Jest matchers', async () => { + expect(page).toBeDefined() + expect(page).not.toBe(null) + + const main = await page.$('main') + expect(main).toBeDefined() + expect(main).not.toBe(null) + }) +})