]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
fix: nightwatch integration (#386)
authorCédric Exbrayat <cexbrayat@users.noreply.github.com>
Mon, 27 Nov 2023 07:37:42 +0000 (08:37 +0100)
committerGitHub <noreply@github.com>
Mon, 27 Nov 2023 07:37:42 +0000 (15:37 +0800)
pnpm-lock.yaml
scripts/test.mjs
template/base/package.json
template/config/nightwatch-ct/package.json
template/config/nightwatch/nightwatch.conf.js
template/config/nightwatch/nightwatch/globals.js [deleted file]
template/config/nightwatch/package.json
template/config/nightwatch/tests/e2e/example.js
template/tsconfig/nightwatch/nightwatch/tsconfig.json
utils/filterList.ts

index ca5f384d87e7bf1e94c93a089b3ab916d5bed4cc..43906d1636dbffca59b21a1de3eb83aa8c7c002b 100644 (file)
@@ -73,7 +73,7 @@ importers:
         specifier: ^4.5.0
         version: 4.5.0(vite@5.0.2)(vue@3.3.8)
       vite:
-        specifier: ^5.0.1
+        specifier: ^5.0.2
         version: 5.0.2(@types/node@18.18.10)
 
   template/config/cypress:
@@ -131,15 +131,16 @@ importers:
       ts-node:
         specifier: ^10.9.1
         version: 10.9.1(@types/node@18.18.10)(typescript@5.2.2)
-      wait-on:
-        specifier: ^7.2.0
-        version: 7.2.0(debug@4.3.4)
 
   template/config/nightwatch-ct:
     dependencies:
       vue:
         specifier: ^3.3.8
         version: 3.3.8(typescript@5.2.2)
+    devDependencies:
+      '@vue/test-utils':
+        specifier: ^2.4.2
+        version: 2.4.2(vue@3.3.8)
 
   template/config/pinia:
     dependencies:
index cab7b948d2d85c66f25c31a2a2ed7a900634966c..fa1a43dcff4f162ab3b2bc1fb292889f03df3def 100644 (file)
@@ -1,9 +1,6 @@
 #!/usr/bin/env zx
 import 'zx/globals'
 
-// Vitest would otherwise enable watch mode by default.
-process.env.CI = '1'
-
 const playgroundDir = path.resolve(__dirname, '../playground/')
 let projects = fs
   .readdirSync(playgroundDir, { withFileTypes: true })
@@ -21,7 +18,13 @@ for (const projectName of projects) {
   cd(path.resolve(playgroundDir, projectName))
   const packageJSON = require(path.resolve(playgroundDir, projectName, 'package.json'))
 
-  console.log(`Building ${projectName}`)
+  console.log(`
+  
+#####
+Building ${projectName}
+#####
+  
+  `)
   await $`pnpm build`
 
   if ('@playwright/test' in packageJSON.devDependencies) {
@@ -35,6 +38,16 @@ for (const projectName of projects) {
 
   if ('test:unit' in packageJSON.scripts) {
     console.log(`Running unit tests in ${projectName}`)
-    await $`pnpm test:unit`
+    if (projectName.includes('vitest') || projectName.includes('with-tests')) {
+      // Vitest would otherwise enable watch mode by default.
+      await $`CI=1 pnpm test:unit`
+    } else {
+      await $`pnpm test:unit`
+    }
+  }
+
+  if ('type-check' in packageJSON.scripts) {
+    console.log(`Running type-check in ${projectName}`)
+    await $`pnpm type-check`
   }
 }
index 5798b2de0e1df59cfd998141af2998ff0efbad36..fa842a7758dc6fb92eea683a848fe2ba77960203 100644 (file)
@@ -10,6 +10,6 @@
   },
   "devDependencies": {
     "@vitejs/plugin-vue": "^4.5.0",
-    "vite": "^5.0.1"
+    "vite": "^5.0.2"
   }
 }
index 9299618bf76f8362537f847dd62203a1239d247a..8982106f534eac3181ea069749e518c73ae89152 100644 (file)
@@ -1,8 +1,11 @@
 {
   "scripts": {
-    "test:unit": "nightwatch src/components/**/__tests__/*"
+    "test:unit": "nightwatch src/**/__tests__/*"
   },
   "dependencies": {
     "vue": "^3.3.8"
+  },
+  "devDependencies": {
+    "@vue/test-utils": "^2.4.2"
   }
 }
index 8ff1700002c38d855a1f8645f0b4fa540e682118..05889c61f6e023ce23b66ca069b629de4d29db72 100644 (file)
@@ -30,10 +30,11 @@ module.exports = {
   plugins: ['@nightwatch/vue'],
 
   // See https://nightwatchjs.org/guide/concepts/test-globals.html#external-test-globals
-  globals_path: 'nightwatch/globals.js',
+  globals_path: '',
 
   vite_dev_server: {
-    start_vite: false
+    start_vite: true,
+    port: process.env.CI ? 4173 : 5173
   },
 
   webdriver: {},
diff --git a/template/config/nightwatch/nightwatch/globals.js b/template/config/nightwatch/nightwatch/globals.js
deleted file mode 100644 (file)
index 9387d35..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-const waitOn = require('wait-on')
-const { setup, teardown } = require('@nightwatch/vue')
-
-const serverPort = process.env.CI ? '4173' : '5173'
-
-module.exports = {
-  before(done) {
-    setup()
-    waitOn({
-      resources: [`http-get://localhost:${serverPort}`],
-      verbose: true,
-      headers: {
-        accept: 'text/html'
-      }
-    }).then(() => {
-      done()
-    })
-  },
-
-  after() {
-    teardown()
-  }
-}
index a77d512d8d1e3581077c29a9fa71d18bfc402931..4f281a775497f793b9223c57a7a726a7be023228 100644 (file)
@@ -1,6 +1,6 @@
 {
   "scripts": {
-    "test:e2e": "nightwatch tests/e2e"
+    "test:e2e": "nightwatch tests/e2e/*"
   },
   "devDependencies": {
     "nightwatch": "^3.3.2",
@@ -9,7 +9,6 @@
     "@types/nightwatch": "^2.3.28",
     "geckodriver": "^4.2.1",
     "chromedriver": "^119.0.0",
-    "ts-node": "^10.9.1",
-    "wait-on": "^7.2.0"
+    "ts-node": "^10.9.1"
   }
 }
index cf2e3c8627118a914bb6174ec224529753f7dc53..43be3fce1c27a581300ee75ff7c0d459597af39f 100644 (file)
@@ -4,10 +4,7 @@ describe('My First Test', function () {
   })
 
   it('visits the app root url', function () {
-    browser.assert
-      .textContains('.green', 'You did it!')
-      .assert.elementHasCount('.wrapper nav a', 2)
-      .strictClick('.wrapper nav a:last-child')
+    browser.assert.textContains('.green', 'You did it!')
   })
 
   after((browser) => browser.end())
index 652d9bd6aee9ec3f99c1ef22260ebc4e343bf248..b4b031b9fdea75740543713cff81b443ec65396f 100644 (file)
@@ -3,6 +3,7 @@
   "compilerOptions": {
     "target": "ESNext",
     "module": "commonjs",
+    "moduleResolution": "node",
     "composite": true,
     "rootDir": "../",
     "lib": ["ESNext", "dom"],
@@ -10,7 +11,7 @@
   },
   "include": ["../node_modules/@nightwatch/**/*", "../src/components/**/*", "../tests/e2e/**/*"],
   "ts-node": {
-    "files": true
+    "transpileOnly": true
   },
   "files": ["nightwatch.d.ts"]
 }
index dd9f9c4639d2a7de3d9646fd0fda8d8fda9c7612..37780156d8e443582d850079a43fa7a35dbe63ad 100644 (file)
@@ -1,5 +1 @@
-export const FILES_TO_FILTER = [
-  'nightwatch.e2e.conf.js',
-  'nightwatch.component.conf.js',
-  'globals.js'
-]
+export const FILES_TO_FILTER = ['nightwatch.e2e.conf.js', 'nightwatch.component.conf.js']