Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Improve test setup #1372

Merged
merged 8 commits into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"testonly": "cross-env NODE_PATH=test/lib jest \\.test.js",
"posttestonly": "fly posttest",
"pretest": "npm run lint && cross-env NODE_ENV=test-build npm run release",
"test": "npm run testonly -- --coverage --forceExit",
"test": "npm run testonly -- --coverage --forceExit --runInBand --verbose --bail",
"coveralls": "nyc --instrument=false --source-map=false report --temp-directory=./coverage --reporter=text-lcov | coveralls",
"lint": "standard 'bin/*' 'client/**/*.js' 'examples/**/*.js' 'lib/**/*.js' 'pages/**/*.js' 'server/**/*.js' 'test/**/*.js'",
"prepublish": "npm run release",
Expand Down
30 changes: 15 additions & 15 deletions test/integration/basic/test/client-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default (context, render) => {
.elementByCss('p').text()

expect(text).toBe('This is the about page.')
await browser.close()
browser.close()
})

it('should navigate via the client side', async () => {
Expand All @@ -28,7 +28,7 @@ export default (context, render) => {
.elementByCss('#counter').text()

expect(counterText).toBe('Counter: 1')
await browser.close()
browser.close()
})
})

Expand All @@ -41,7 +41,7 @@ export default (context, render) => {
.elementByCss('p').text()

expect(text).toBe('This is the home.')
await browser.close()
browser.close()
})
})

Expand All @@ -56,7 +56,7 @@ export default (context, render) => {
const expectedErrorMessage = '"EmptyInitialPropsPage.getInitialProps()" should resolve to an object. But found "null" instead.'
expect(preText.includes(expectedErrorMessage)).toBeTruthy()

await browser.close()
browser.close()
})
})

Expand All @@ -69,7 +69,7 @@ export default (context, render) => {
.elementByCss('p').text()

expect(text).toBe('2')
await browser.close()
browser.close()
})

it('should remove querystring', async () => {
Expand All @@ -80,7 +80,7 @@ export default (context, render) => {
.elementByCss('p').text()

expect(text).toBe('0')
await browser.close()
browser.close()
})
})

Expand All @@ -95,7 +95,7 @@ export default (context, render) => {
.elementByCss('p').text()

expect(countAfterClicked).toBe('COUNT: 1')
await browser.close()
browser.close()
})

it('should always replace the state', async () => {
Expand All @@ -116,7 +116,7 @@ export default (context, render) => {
.back()
.waitForElementByCss('.nav-home')

await browser.close()
browser.close()
})
})

Expand All @@ -131,7 +131,7 @@ export default (context, render) => {

expect(counter).toBe('COUNT: 0')

await browser.close()
browser.close()
})
})

Expand All @@ -145,7 +145,7 @@ export default (context, render) => {

expect(counter).toBe('COUNT: 0')

await browser.close()
browser.close()
})
})

Expand All @@ -160,7 +160,7 @@ export default (context, render) => {

expect(counter).toBe('COUNT: 1')

await browser.close()
browser.close()
})
})

Expand All @@ -175,7 +175,7 @@ export default (context, render) => {

expect(counter).toBe('COUNT: 0')

await browser.close()
browser.close()
})
})
})
Expand All @@ -193,7 +193,7 @@ export default (context, render) => {
.elementByCss('#get-initial-props-run-count').text()
expect(getInitialPropsRunCount).toBe('getInitialProps run count: 1')

await browser.close()
browser.close()
})

it('should handle the back button and should not run getInitialProps', async () => {
Expand All @@ -213,7 +213,7 @@ export default (context, render) => {
.elementByCss('#get-initial-props-run-count').text()
expect(getInitialPropsRunCount).toBe('getInitialProps run count: 1')

await browser.close()
browser.close()
})

it('should run getInitialProps always when rending the page to the screen', async () => {
Expand All @@ -233,7 +233,7 @@ export default (context, render) => {
.elementByCss('#get-initial-props-run-count').text()
expect(getInitialPropsRunCount).toBe('getInitialProps run count: 2')

await browser.close()
browser.close()
})
})
})
Expand Down
2 changes: 2 additions & 0 deletions test/lib/next-webdriver.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import wd from 'wd'

export default async function (appPort, pathname) {
console.warn(`> Start loading browser with path: ${pathname}`)
const url = `http://localhost:${appPort}${pathname}`

const browser = wd.promiseChainRemote('http://localhost:9515/')
await browser.init({browserName: 'chrome'}).get(url)

console.warn(`> Complete loading browser with path: ${pathname}`)
return browser
}