Skip to content

Commit 5c4926e

Browse files
authored
fix: nightwatch integration (#386)
1 parent 8b6c2cd commit 5c4926e

File tree

10 files changed

+37
-49
lines changed

10 files changed

+37
-49
lines changed

pnpm-lock.yaml

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/test.mjs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/usr/bin/env zx
22
import 'zx/globals'
33

4-
// Vitest would otherwise enable watch mode by default.
5-
process.env.CI = '1'
6-
74
const playgroundDir = path.resolve(__dirname, '../playground/')
85
let projects = fs
96
.readdirSync(playgroundDir, { withFileTypes: true })
@@ -21,7 +18,13 @@ for (const projectName of projects) {
2118
cd(path.resolve(playgroundDir, projectName))
2219
const packageJSON = require(path.resolve(playgroundDir, projectName, 'package.json'))
2320

24-
console.log(`Building ${projectName}`)
21+
console.log(`
22+
23+
#####
24+
Building ${projectName}
25+
#####
26+
27+
`)
2528
await $`pnpm build`
2629

2730
if ('@playwright/test' in packageJSON.devDependencies) {
@@ -35,6 +38,16 @@ for (const projectName of projects) {
3538

3639
if ('test:unit' in packageJSON.scripts) {
3740
console.log(`Running unit tests in ${projectName}`)
38-
await $`pnpm test:unit`
41+
if (projectName.includes('vitest') || projectName.includes('with-tests')) {
42+
// Vitest would otherwise enable watch mode by default.
43+
await $`CI=1 pnpm test:unit`
44+
} else {
45+
await $`pnpm test:unit`
46+
}
47+
}
48+
49+
if ('type-check' in packageJSON.scripts) {
50+
console.log(`Running type-check in ${projectName}`)
51+
await $`pnpm type-check`
3952
}
4053
}

template/base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
},
1111
"devDependencies": {
1212
"@vitejs/plugin-vue": "^4.5.0",
13-
"vite": "^5.0.1"
13+
"vite": "^5.0.2"
1414
}
1515
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"scripts": {
3-
"test:unit": "nightwatch src/components/**/__tests__/*"
3+
"test:unit": "nightwatch src/**/__tests__/*"
44
},
55
"dependencies": {
66
"vue": "^3.3.8"
7+
},
8+
"devDependencies": {
9+
"@vue/test-utils": "^2.4.2"
710
}
811
}

template/config/nightwatch/nightwatch.conf.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ module.exports = {
3030
plugins: ['@nightwatch/vue'],
3131

3232
// See https://nightwatchjs.org/guide/concepts/test-globals.html#external-test-globals
33-
globals_path: 'nightwatch/globals.js',
33+
globals_path: '',
3434

3535
vite_dev_server: {
36-
start_vite: false
36+
start_vite: true,
37+
port: process.env.CI ? 4173 : 5173
3738
},
3839

3940
webdriver: {},

template/config/nightwatch/nightwatch/globals.js

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"scripts": {
3-
"test:e2e": "nightwatch tests/e2e"
3+
"test:e2e": "nightwatch tests/e2e/*"
44
},
55
"devDependencies": {
66
"nightwatch": "^3.3.2",
@@ -9,7 +9,6 @@
99
"@types/nightwatch": "^2.3.28",
1010
"geckodriver": "^4.2.1",
1111
"chromedriver": "^119.0.0",
12-
"ts-node": "^10.9.1",
13-
"wait-on": "^7.2.0"
12+
"ts-node": "^10.9.1"
1413
}
1514
}

template/config/nightwatch/tests/e2e/example.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ describe('My First Test', function () {
44
})
55

66
it('visits the app root url', function () {
7-
browser.assert
8-
.textContains('.green', 'You did it!')
9-
.assert.elementHasCount('.wrapper nav a', 2)
10-
.strictClick('.wrapper nav a:last-child')
7+
browser.assert.textContains('.green', 'You did it!')
118
})
129

1310
after((browser) => browser.end())

template/tsconfig/nightwatch/nightwatch/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"compilerOptions": {
44
"target": "ESNext",
55
"module": "commonjs",
6+
"moduleResolution": "node",
67
"composite": true,
78
"rootDir": "../",
89
"lib": ["ESNext", "dom"],
910
"types": ["nightwatch"]
1011
},
1112
"include": ["../node_modules/@nightwatch/**/*", "../src/components/**/*", "../tests/e2e/**/*"],
1213
"ts-node": {
13-
"files": true
14+
"transpileOnly": true
1415
},
1516
"files": ["nightwatch.d.ts"]
1617
}

utils/filterList.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
export const FILES_TO_FILTER = [
2-
'nightwatch.e2e.conf.js',
3-
'nightwatch.component.conf.js',
4-
'globals.js'
5-
]
1+
export const FILES_TO_FILTER = ['nightwatch.e2e.conf.js', 'nightwatch.component.conf.js']

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy