Update RegExp test and remove extra script (#11006)

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
This commit is contained in:
JJ Kasper 2020-03-12 13:24:44 -05:00 committed by GitHub
parent 8f8030f7eb
commit 9943334d44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 21 deletions

View file

@ -3,5 +3,4 @@ node_modules
**/_next/**
**/dist/**
examples/with-ioc/**
examples/with-kea/**
test/integration/production/public/**/*
examples/with-kea/**

View file

@ -1,5 +1,4 @@
node_modules
**/.next/**
**/_next/**
**/dist/**
test/integration/production/public/**/*
**/dist/**

View file

@ -1,4 +1,3 @@
**/.next/**
**/_next/**
**/dist/**
test/integration/production/public/**/*
**/dist/**

View file

@ -1,12 +1,23 @@
export default () => {
import * as React from 'react'
const Home = () => {
if (typeof window !== 'undefined') {
window.didRender = true
}
React.useEffect(() => {
// If this script is loaded before the polyfills it will
// still fail
const el = document.createElement('script')
el.src = '/regexp-test.js'
document.querySelector('body').appendChild(el)
}, [])
return (
<>
<p>hi</p>
<script src="/regexp-test.js" />
</>
)
}
export default Home

File diff suppressed because one or more lines are too long

View file

@ -64,6 +64,12 @@ describe('Production Usage', () => {
it('should polyfill RegExp successfully', async () => {
const browser = await webdriver(appPort, '/regexp-polyfill')
expect(await browser.eval('window.didRender')).toBe(true)
// wait a second for the script to be loaded
await waitFor(1000)
expect(await browser.eval('window.isSticky')).toBe(true)
expect(await browser.eval('window.isMatch1')).toBe(true)
expect(await browser.eval('window.isMatch2')).toBe(false)
})
}