Skip to content

Commit

Permalink
test: fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fangbinwei committed Nov 30, 2020
1 parent d9351ef commit f67bc93
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,27 @@ describe('nightwatch e2e plugin', () => {
})

test('should accept the --url cli option', async () => {
await project.run(`vue-cli-service build`)
const server = createServer({ root: path.join(project.dir, 'dist') })
await new Promise((resolve, reject) => {
server.listen(8080, err => {
if (err) return reject(err)
resolve()
let server
try {
await project.run(`vue-cli-service build`)
server = createServer({ root: path.join(project.dir, 'dist') })
await new Promise((resolve, reject) => {
server.listen(8080, err => {
if (err) return reject(err)
resolve()
})
})
})
await project.run(`vue-cli-service test:e2e --headless --url http://127.0.0.1:8080/`)
server.close()

let results = await project.read('test_results.json')
results = JSON.parse(results)
expect(Object.keys(results.modules)).toEqual([
'test-with-pageobjects',
'test'
])
await project.run(`vue-cli-service test:e2e --headless --url http://127.0.0.1:8080/`)

let results = await project.read('test_results.json')
results = JSON.parse(results)
expect(Object.keys(results.modules)).toEqual([
'test-with-pageobjects',
'test'
])
} finally {
server && server.close()
}
})

test('should run single test with custom nightwatch.json', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ test('should persist cache', async () => {
server.stdout.on('data', data => {
data = data.toString()
if (data.match(/Compiled successfully/)) {
server.stdin.write('close')
done()
}
})

await donePromise
server.kill('SIGTERM')

expect(has('node_modules/.cache/.eslintcache')).toBe(true)
})

0 comments on commit f67bc93

Please sign in to comment.