]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: run on ci try
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 9 Jun 2022 12:11:24 +0000 (14:11 +0200)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Thu, 30 Jun 2022 07:59:00 +0000 (09:59 +0200)
.github/workflows/test.yml
packages/router/e2e/local.runner.js [deleted file]
packages/router/e2e/runner.js [new file with mode: 0644]
packages/router/e2e/specs/encoding.js
packages/router/nightwatch.conf.js
packages/router/package.json

index 1a2d631dbef62dbe6a7e0cef285ad0d809f25aac..fd54e3c6c044ccdd873e0ec4844d5ec2dee8d062 100644 (file)
@@ -31,7 +31,6 @@ jobs:
       - run: pnpm run -r build
       - run: pnpm run -r build:dts
       - run: pnpm run -r test:dts
-      # TODO: add when doable
-      # - run: pnpm run -r test:e2e:ci
+      - run: pnpm run -r test:e2e:ci
 
       - uses: codecov/codecov-action@v2
diff --git a/packages/router/e2e/local.runner.js b/packages/router/e2e/local.runner.js
deleted file mode 100644 (file)
index d9a0d40..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-require('dotenv').config()
-const Nightwatch = require('nightwatch')
-const browserstack = require('browserstack-local')
-const path = require('path')
-
-const { BROWSERSTACK_ACCESS_KEY } = process.env
-if (!BROWSERSTACK_ACCESS_KEY) {
-  throw new Error(
-    `
-(ONLY FOR MAINTAINERS)
-BROWSERSTACK_ACCESS_KEY is not set. Did you create the .env file?
-`
-  )
-}
-
-try {
-  require.main.filename = path.resolve(
-    __dirname,
-    '../../../node_modules/.bin/nightwatch'
-  )
-
-  // Code to start browserstack local before start of test
-  console.log('Connecting local')
-
-  const bs_local = new browserstack.Local()
-  Nightwatch.bs_local = bs_local
-
-  bs_local.start(
-    { key: process.env.BROWSERSTACK_ACCESS_KEY },
-    function (error) {
-      if (error) throw error
-
-      console.log('Connected. Now testing...')
-      Nightwatch.cli(function (argv) {
-        Nightwatch.CliRunner(argv)
-          .setup()
-          .runTests()
-          .catch(err => {
-            throw err
-          })
-          .finally(() => {
-            // Code to stop browserstack local after end of single test
-            bs_local.stop(function () {})
-          })
-      })
-    }
-  )
-} catch (ex) {
-  console.log('There was an error while starting the test runner:\n\n')
-  process.stderr.write(ex.stack + '\n')
-  process.exit(2)
-}
diff --git a/packages/router/e2e/runner.js b/packages/router/e2e/runner.js
new file mode 100644 (file)
index 0000000..0f29036
--- /dev/null
@@ -0,0 +1,64 @@
+require('dotenv').config()
+const Nightwatch = require('nightwatch')
+const browserstack = require('browserstack-local')
+const path = require('path')
+
+const { BROWSERSTACK_ACCESS_KEY } = process.env
+if (!BROWSERSTACK_ACCESS_KEY) {
+  throw new Error(
+    `
+(ONLY FOR MAINTAINERS)
+BROWSERSTACK_ACCESS_KEY is not set. Did you create the .env file?
+`
+  )
+}
+
+const args = process.argv.slice(2)
+
+// allow running browserstack local
+// note this works because nighwatch doesn't use this option
+const isLocal = args.indexOf('--local') > -1
+
+try {
+  require.main.filename = path.resolve(
+    __dirname,
+    '../../../node_modules/.bin/nightwatch'
+  )
+
+  // Code to start browserstack local before start of test
+  console.log('Connecting local')
+
+  /** @type {import('browserstack-local').Local} */
+  let bs_local
+  if (isLocal) {
+    bs_local = new browserstack.Local()
+    Nightwatch.bs_local = bs_local
+
+    bs_local.start(
+      { key: process.env.BROWSERSTACK_ACCESS_KEY },
+      async error => {
+        if (error) throw error
+
+        console.log('Connected. Now testing...')
+        await runNighwatchCli().finally(() => {
+          // Code to stop browserstack local after end of single test
+          bs_local.stop(() => {})
+        })
+      }
+    )
+  } else {
+    runNighwatchCli()
+  }
+} catch (ex) {
+  console.log('There was an error while starting the test runner:\n\n')
+  process.stderr.write(ex.stack + '\n')
+  process.exit(2)
+}
+
+function runNighwatchCli() {
+  return new Promise((resolve, reject) => {
+    Nightwatch.cli(argv => {
+      Nightwatch.CliRunner(argv).setup().runTests().then(resolve).catch(reject)
+    })
+  })
+}
index 17bcb535a53d1495352c5055452a8e8ae8584cff..c55fdc3d2068c7792aed7a88fa63f0f95b780ee8 100644 (file)
@@ -20,9 +20,9 @@ module.exports = {
 
       .click('li:nth-child(3) a')
       .assert.urlEquals(baseURL + '/documents/%E2%82%ACuro')
-      .assert.containsText('#fullPath', '/documents/%E2%82%ACuro')
-      .assert.containsText('#path', '/documents/%E2%82%ACuro')
-      .assert.containsText('#p-id', '"€uro"')
+      .assert.textContains('#fullPath', '/documents/%E2%82%ACuro')
+      .assert.textContains('#path', '/documents/%E2%82%ACuro')
+      .assert.textContains('#p-id', '"€uro"')
 
       // full encoding test
       .click('li:nth-child(8) a')
@@ -48,16 +48,16 @@ module.exports = {
     browser
       .url(baseURL + '/documents/%E2%82%ACuro')
       .waitForElementPresent('#app > *', TIMEOUT)
-      // .assert.containsText('#fullPath', '/documents/%E2%82%ACuro')
-      // .assert.containsText('#path', '/documents/%E2%82%ACuro')
-      .assert.containsText('#p-id', '"€uro"')
+      // .assert.textContains('#fullPath', '/documents/%E2%82%ACuro')
+      // .assert.textContains('#path', '/documents/%E2%82%ACuro')
+      .assert.textContains('#p-id', '"€uro"')
 
       // TODO: invalid in safari, tests on those where this is valid
       // .url(baseURL + '/unicode/€uro')
       // .waitForElementPresent('#app > *', TIMEOUT)
       // navigation to unencoded value
       // depending on the browser the value will be encoded or not
-      // .assert.containsText('#params', JSON.stringify({ id: '€uro' }, null, 2))
+      // .assert.textContains('#params', JSON.stringify({ id: '€uro' }, null, 2))
 
       .end()
   },
index 28a977b8706bd9dc9b4263223076b08454b1ed46..ba1ccf1994e9a002c83f19f72f914510ce39b6d4 100644 (file)
@@ -50,16 +50,12 @@ module.exports = {
         browserName: 'chrome',
         'goog:chromeOptions': {
           w3c: true,
-          args: ['window-size=1280,800', 'headless'],
         },
       },
 
       webdriver: {
         start_process: true,
         server_path: '',
-        cli_args: [
-          // --verbose
-        ],
       },
     },
 
@@ -124,6 +120,13 @@ module.exports = {
 
     'chrome-headless': {
       extends: 'default',
+      desiredCapabilities: {
+        browserName: 'chrome',
+        'goog:chromeOptions': {
+          w3c: true,
+          args: ['window-size=1280,800', 'headless'],
+        },
+      },
     },
 
     edge: {
@@ -189,30 +192,6 @@ module.exports = {
       },
     },
 
-    'browserstack.chrome': {
-      extends: 'browserstack',
-      desiredCapabilities: {
-        browserName: 'chrome',
-        chromeOptions: {
-          w3c: true,
-        },
-      },
-    },
-
-    'browserstack.firefox': {
-      extends: 'browserstack',
-      desiredCapabilities: {
-        browserName: 'firefox',
-      },
-    },
-
-    'browserstack.safari': {
-      extends: 'browserstack',
-      desiredCapabilities: {
-        browserName: 'safari',
-      },
-    },
-
     'browserstack.local_chrome': {
       extends: 'browserstack.local',
       desiredCapabilities: {
index 63eb30eb1bde52081f197d1c576b5df6616e603a..cb47bf0ed633494b228bb81ccc6a5a0ffa217ee5 100644 (file)
     "test:unit": "jest --coverage",
     "test": "pnpm run test:types && pnpm run test:unit && pnpm run build && pnpm run build:dts && pnpm run test:e2e",
     "test:e2e": "pnpm run test:e2e:headless && pnpm run test:e2e:native",
-    "test:e2e:headless": "node e2e/runner.js -e chrome-headless --skiptags no-headless",
-    "test:e2e:native": "node e2e/runner.js -e chrome --tag no-headless",
-    "test:e2e:ci": "node e2e/runner.js -e firefox --retries 2",
-    "test:e2e:bs": "node e2e/local.runner.js -e edge_pre_chrome,android44 --tag browserstack"
+    "test:e2e:headless": "nightwatch --skiptags no-headless",
+    "test:e2e:native": "nightwatch --env chrome",
+    "test:e2e:ci": "nightwatch --env chrome --retries 2",
+    "test:e2e:bs": "node e2e/runner.js -e edge_pre_chrome,android44 --tag browserstack"
   },
   "gitHooks": {
     "pre-commit": "lint-staged",