From: Eduardo San Martin Morote Date: Wed, 8 Jun 2022 16:49:42 +0000 (+0200) Subject: chore: upgrade nightwatch X-Git-Tag: v4.1.0~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e4cd9371d35c87362af7c5a180abf7dd0c5fae0a;p=thirdparty%2Fvuejs%2Frouter.git chore: upgrade nightwatch --- diff --git a/packages/router/.gitignore b/packages/router/.gitignore index 9f7024d4..6b1632b9 100644 --- a/packages/router/.gitignore +++ b/packages/router/.gitignore @@ -2,3 +2,5 @@ e2e/reports e2e/screenshots old-e2e/reports old-e2e/screenshots +tests_output +logs diff --git a/packages/router/old-e2e/encoding/index.html b/packages/router/e2e/encoding/index.html similarity index 100% rename from packages/router/old-e2e/encoding/index.html rename to packages/router/e2e/encoding/index.html diff --git a/packages/router/old-e2e/encoding/index.ts b/packages/router/e2e/encoding/index.ts similarity index 96% rename from packages/router/old-e2e/encoding/index.ts rename to packages/router/e2e/encoding/index.ts index d9361c6c..d9117022 100644 --- a/packages/router/old-e2e/encoding/index.ts +++ b/packages/router/e2e/encoding/index.ts @@ -1,6 +1,5 @@ import '../global.css' -import { createRouter, createWebHistory } from '../../src' -import { RouteComponent } from '../../src/types' +import { createRouter, createWebHistory, RouteComponent } from 'vue-router' import { createApp, defineComponent, FunctionalComponent, h } from 'vue' const component: RouteComponent = { diff --git a/packages/router/old-e2e/global.css b/packages/router/e2e/global.css similarity index 100% rename from packages/router/old-e2e/global.css rename to packages/router/e2e/global.css diff --git a/packages/router/old-e2e/index.html b/packages/router/e2e/index.html similarity index 100% rename from packages/router/old-e2e/index.html rename to packages/router/e2e/index.html diff --git a/packages/router/old-e2e/index.ts b/packages/router/e2e/index.ts similarity index 63% rename from packages/router/old-e2e/index.ts rename to packages/router/e2e/index.ts index fdae87ee..a7d652d0 100644 --- a/packages/router/old-e2e/index.ts +++ b/packages/router/e2e/index.ts @@ -12,21 +12,9 @@ const examples: string[] = Object.keys(tsmap) .map(match => match![1] + '/') .sort() -// const context = require.context('.', true, /^.{2,}\/index\.ts$/) -// const DIR_RE = /^\.\/([^/]+)\// - -// const examples: string[] = [] -// context.keys().forEach(path => { -// const match = DIR_RE.exec(path) -// if (match) examples.push(match[1]) -// return name -// }) - -examples.sort() - declare global { interface Window { - app: App + app: App vm: ComponentPublicInstance r: Router } diff --git a/packages/router/old-e2e/specs/encoding.js b/packages/router/e2e/specs/encoding.js similarity index 94% rename from packages/router/old-e2e/specs/encoding.js rename to packages/router/e2e/specs/encoding.js index 05c6a48b..17bcb535 100644 --- a/packages/router/old-e2e/specs/encoding.js +++ b/packages/router/e2e/specs/encoding.js @@ -1,4 +1,4 @@ -const bsStatus = require('../browserstack-send-status') +// const bsStatus = require('../browserstack-send-status') const baseURL = 'http://localhost:3000/encoding' @@ -7,12 +7,12 @@ const rawText = ' !"#$&\'()*+,/:;<=>?@[]^`{|}' const TIMEOUT = 2000 module.exports = { - ...bsStatus(), + // ...bsStatus(), '@tags': ['history', 'encoding', 'browserstack'], /** @type {import('nightwatch').NightwatchTest} */ - 'encodes values': function (browser) { + 'encodes values'(browser) { browser .url(baseURL + '/') .assert.urlEquals(baseURL + '/') diff --git a/packages/router/old-e2e/tsconfig.json b/packages/router/e2e/tsconfig.json similarity index 83% rename from packages/router/old-e2e/tsconfig.json rename to packages/router/e2e/tsconfig.json index d61bd724..f5ea3fe7 100644 --- a/packages/router/old-e2e/tsconfig.json +++ b/packages/router/e2e/tsconfig.json @@ -2,7 +2,7 @@ "include": ["index.ts", "*/*.ts", "../src/global.d.ts"], "compilerOptions": { "target": "es6", - "module": "commonjs", + "module": "ESNext", // "lib": ["es2017.object"] /* Specify library files to be included in the compilation. */, "declaration": true, // "declarationMap": true, @@ -19,6 +19,9 @@ "moduleResolution": "node", "esModuleInterop": true, - "types": ["vite/client"] + "types": ["vite/client"], + "paths": { + "vue-router": ["../src"] + } } } diff --git a/packages/router/old-e2e/vite.config.js b/packages/router/e2e/vite.config.ts similarity index 83% rename from packages/router/old-e2e/vite.config.js rename to packages/router/e2e/vite.config.ts index 2755f979..67a562f8 100644 --- a/packages/router/old-e2e/vite.config.js +++ b/packages/router/e2e/vite.config.ts @@ -1,11 +1,10 @@ -const fs = require('fs') -const { resolve, join } = require('path') -const { defineConfig } = require('vite') -const vue = require('@vitejs/plugin-vue') -const history = require('connect-history-api-fallback') +import fs from 'fs' +import { resolve, join } from 'path' +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import history from 'connect-history-api-fallback' -/** @type {string[]} */ -let examples = [] +const examples: string[] = [] fs.readdirSync(__dirname).forEach(dir => { const fullDir = join(__dirname, dir) const entry = join(fullDir, 'index.ts') @@ -15,7 +14,7 @@ fs.readdirSync(__dirname).forEach(dir => { }) // https://vitejs.dev/config/ -const config = (env = {}) => { +const config = (env: Record = {}) => { return defineConfig({ root: resolve(__dirname), resolve: { @@ -28,23 +27,26 @@ const config = (env = {}) => { }, build: { outDir: join(__dirname, '__build__'), - filename: '[name].js', - chunkFilename: '[id].chunk.js', - publicPath: '/', + // publicPath: '/', rollupOptions: { + output: { + file: '[name].js', + chunkFileNames: '[id].chunk.js', + }, plugins: [], input: examples.reduce( (entries, name) => { entries[name] = resolve(__dirname, name, 'index.html') return entries }, - { index: resolve(__dirname, 'index.html') } + { index: resolve(__dirname, 'index.html') } as Record ), }, }, plugins: [ vue(), { + name: 'custom history', configureServer({ middlewares }) { middlewares.use( history({ diff --git a/packages/router/nightwatch.conf.js b/packages/router/nightwatch.conf.js new file mode 100644 index 00000000..de2d5fd5 --- /dev/null +++ b/packages/router/nightwatch.conf.js @@ -0,0 +1,356 @@ +// +// Refer to the online docs for more details: +// https://nightwatchjs.org/gettingstarted/configuration/ +// +// _ _ _ _ _ _ _ +// | \ | |(_) | | | | | | | | +// | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__ +// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \ +// | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | | +// \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_| +// __/ | +// |___/ +// + +module.exports = { + // An array of folders (excluding subfolders) where your tests are located; + // if this is not specified, the test source must be passed as the second argument to the test runner. + src_folders: [], + + // See https://nightwatchjs.org/guide/working-with-page-objects/using-page-objects.html + page_objects_path: ['node_modules/nightwatch/examples/pages/'], + + // See https://nightwatchjs.org/guide/extending-nightwatch/custom-commands.html + custom_commands_path: ['node_modules/nightwatch/examples/custom-commands/'], + + // See https://nightwatchjs.org/guide/extending-nightwatch/custom-assertions.html + custom_assertions_path: '', + + // See https://nightwatchjs.org/guide/extending-nightwatch/plugin-api.html + plugins: [], + + // See https://nightwatchjs.org/guide/#external-globals + globals_path: '', + + webdriver: {}, + + test_settings: { + default: { + disable_error_log: false, + launch_url: 'https://nightwatchjs.org', + + screenshots: { + enabled: false, + path: 'screens', + on_failure: true, + }, + + desiredCapabilities: { + browserName: 'firefox', + }, + + webdriver: { + start_process: true, + server_path: '', + }, + }, + + safari: { + desiredCapabilities: { + browserName: 'safari', + alwaysMatch: { + acceptInsecureCerts: false, + }, + }, + webdriver: { + start_process: true, + server_path: '', + }, + }, + + firefox: { + desiredCapabilities: { + browserName: 'firefox', + alwaysMatch: { + acceptInsecureCerts: true, + 'moz:firefoxOptions': { + args: [ + // '-headless', + // '-verbose' + ], + }, + }, + }, + webdriver: { + start_process: true, + server_path: '', + cli_args: [ + // very verbose geckodriver logs + // '-vv' + ], + }, + }, + + chrome: { + desiredCapabilities: { + browserName: 'chrome', + 'goog:chromeOptions': { + // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/ + // + // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78) + w3c: true, + args: [ + //'--no-sandbox', + //'--ignore-certificate-errors', + //'--allow-insecure-localhost', + //'--headless' + ], + }, + }, + + webdriver: { + start_process: true, + server_path: '', + cli_args: [ + // --verbose + ], + }, + }, + + edge: { + desiredCapabilities: { + browserName: 'MicrosoftEdge', + 'ms:edgeOptions': { + w3c: true, + // More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options + args: [ + //'--headless' + ], + }, + }, + + webdriver: { + start_process: true, + // Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ + // and set the location below: + server_path: '', + cli_args: [ + // --verbose + ], + }, + }, + + ////////////////////////////////////////////////////////////////////////////////// + // Configuration for when using cucumber-js (https://cucumber.io) | + // | + // It uses the bundled examples inside the nightwatch examples folder; feel free | + // to adapt this to your own project needs | + ////////////////////////////////////////////////////////////////////////////////// + 'cucumber-js': { + src_folders: ['examples/cucumber-js/features/step_definitions'], + + test_runner: { + // set cucumber as the runner + type: 'cucumber', + + // define cucumber specific options + options: { + //set the feature path + feature_path: + 'node_modules/nightwatch/examples/cucumber-js/*/*.feature', + + // start the webdriver session automatically (enabled by default) + // auto_start_session: true + + // use parallel execution in Cucumber + // parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2 + }, + }, + }, + + ////////////////////////////////////////////////////////////////////////////////// + // Configuration for when using the browserstack.com cloud service | + // | + // Please set the username and access key by setting the environment variables: | + // - BROWSERSTACK_USERNAME | + // - BROWSERSTACK_ACCESS_KEY | + // .env files are supported | + ////////////////////////////////////////////////////////////////////////////////// + browserstack: { + selenium: { + host: 'hub.browserstack.com', + port: 443, + }, + // More info on configuring capabilities can be found on: + // https://www.browserstack.com/automate/capabilities?tag=selenium-4 + desiredCapabilities: { + 'bstack:options': { + userName: '${BROWSERSTACK_USERNAME}', + accessKey: '${BROWSERSTACK_ACCESS_KEY}', + }, + }, + + disable_error_log: true, + webdriver: { + timeout_options: { + timeout: 15000, + retry_attempts: 3, + }, + keep_alive: true, + start_process: false, + }, + }, + + 'browserstack.local': { + extends: 'browserstack', + desiredCapabilities: { + 'browserstack.local': true, + }, + }, + + 'browserstack.chrome': { + extends: 'browserstack', + desiredCapabilities: { + browserName: 'chrome', + chromeOptions: { + w3c: true, + }, + }, + }, + + 'browserstack.firefox': { + extends: 'browserstack', + desiredCapabilities: { + browserName: 'firefox', + }, + }, + + 'browserstack.ie': { + extends: 'browserstack', + desiredCapabilities: { + browserName: 'internet explorer', + browserVersion: '11.0', + }, + }, + + 'browserstack.safari': { + extends: 'browserstack', + desiredCapabilities: { + browserName: 'safari', + }, + }, + + 'browserstack.local_chrome': { + extends: 'browserstack.local', + desiredCapabilities: { + browserName: 'chrome', + }, + }, + + 'browserstack.local_firefox': { + extends: 'browserstack.local', + desiredCapabilities: { + browserName: 'firefox', + }, + }, + ////////////////////////////////////////////////////////////////////////////////// + // Configuration for when using the SauceLabs cloud service | + // | + // Please set the username and access key by setting the environment variables: | + // - SAUCE_USERNAME | + // - SAUCE_ACCESS_KEY | + ////////////////////////////////////////////////////////////////////////////////// + saucelabs: { + selenium: { + host: 'ondemand.saucelabs.com', + port: 443, + }, + // More info on configuring capabilities can be found on: + // https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options + desiredCapabilities: { + 'sauce:options': { + username: '${SAUCE_USERNAME}', + accessKey: '${SAUCE_ACCESS_KEY}', + screenResolution: '1280x1024', + // https://docs.saucelabs.com/dev/cli/sauce-connect-proxy/#--region + // region: 'us-west-1' + // https://docs.saucelabs.com/dev/test-configuration-options/#tunnelidentifier + // parentTunnel: '', + // tunnelIdentifier: '', + }, + }, + disable_error_log: false, + webdriver: { + start_process: false, + }, + }, + 'saucelabs.chrome': { + extends: 'saucelabs', + desiredCapabilities: { + browserName: 'chrome', + browserVersion: 'latest', + javascriptEnabled: true, + acceptSslCerts: true, + timeZone: 'London', + chromeOptions: { + w3c: true, + }, + }, + }, + 'saucelabs.firefox': { + extends: 'saucelabs', + desiredCapabilities: { + browserName: 'firefox', + browserVersion: 'latest', + javascriptEnabled: true, + acceptSslCerts: true, + timeZone: 'London', + }, + }, + ////////////////////////////////////////////////////////////////////////////////// + // Configuration for when using the Selenium service, either locally or remote, | + // like Selenium Grid | + ////////////////////////////////////////////////////////////////////////////////// + selenium_server: { + // Selenium Server is running locally and is managed by Nightwatch + // Install the NPM package @nightwatch/selenium-server or download the selenium server jar file from https://github.com/SeleniumHQ/selenium/releases/, e.g.: selenium-server-4.1.1.jar + selenium: { + start_process: true, + port: 4444, + server_path: '', // Leave empty if @nightwatch/selenium-server is installed + command: 'standalone', // Selenium 4 only + cli_args: { + //'webdriver.gecko.driver': '', + //'webdriver.chrome.driver': '' + }, + }, + webdriver: { + start_process: false, + default_path_prefix: '/wd/hub', + }, + }, + + 'selenium.chrome': { + extends: 'selenium_server', + desiredCapabilities: { + browserName: 'chrome', + chromeOptions: { + w3c: true, + }, + }, + }, + + 'selenium.firefox': { + extends: 'selenium_server', + desiredCapabilities: { + browserName: 'firefox', + 'moz:firefoxOptions': { + args: [ + // '-headless', + // '-verbose' + ], + }, + }, + }, + }, +} diff --git a/packages/router/package.json b/packages/router/package.json index 209e414b..ab644380 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -55,7 +55,7 @@ "build:playground": "vue-tsc --noEmit && vite build --config playground/vite.config.js", "build:e2e": "vue-tsc --noEmit && vite build --config e2e/vite.config.js", "build:size": "yarn run build && rollup -c size-checks/rollup.config.js", - "dev:e2e": "vite --config e2e/vite.config.js", + "dev:e2e": "vite --config e2e/vite.config.ts", "docs": "vitepress dev docs", "docs:build": "vitepress build docs", "lint": "yarn run lint:script && yarn run lint:html", @@ -103,6 +103,7 @@ "@sucrase/jest-plugin": "^2.1.1", "@types/jest": "^27.4.1", "@types/jsdom": "^16.2.13", + "@types/nightwatch": "^2.0.8", "@vitejs/plugin-vue": "^2.2.2", "@vue/compiler-sfc": "^3.2.31", "@vue/server-renderer": "^3.2.31", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d37753d0..dc26dee5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,6 +21,7 @@ importers: '@sucrase/jest-plugin': ^2.1.1 '@types/jest': ^27.4.1 '@types/jsdom': ^16.2.13 + '@types/nightwatch': ^2.0.8 '@vitejs/plugin-vue': ^2.2.2 '@vue/compiler-sfc': ^3.2.31 '@vue/devtools-api': ^6.1.4 @@ -65,6 +66,7 @@ importers: '@sucrase/jest-plugin': 2.2.1 '@types/jest': 27.5.2 '@types/jsdom': 16.2.14 + '@types/nightwatch': 2.0.8 '@vitejs/plugin-vue': 2.3.3_vite@2.9.10+vue@3.2.37 '@vue/compiler-sfc': 3.2.37 '@vue/server-renderer': 3.2.37_vue@3.2.37 @@ -1128,6 +1130,12 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true + /@types/nightwatch/2.0.8: + resolution: {integrity: sha512-QxWcHZjdkNRU+524zOkwt5N809pcBklymGVfCGIzWPdf0s2Y573pXNkIomQ4ZFjxyvPevg8izZflQ7DMyeE8HA==} + dependencies: + '@types/selenium-webdriver': 4.1.1 + dev: true + /@types/node/12.20.24: resolution: {integrity: sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ==} dev: true @@ -1160,6 +1168,12 @@ packages: '@types/node': 17.0.41 dev: true + /@types/selenium-webdriver/4.1.1: + resolution: {integrity: sha512-NxxZZek50ylIACiXebKQYHD3D4One3WXOasEXWazL6aTfYbZob7ClNKxUpg8I4/oWArX87oPWvj1cHKqfel3Hg==} + dependencies: + '@types/ws': 8.5.3 + dev: true + /@types/stack-utils/2.0.1: resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==} dev: true @@ -1168,6 +1182,12 @@ packages: resolution: {integrity: sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==} dev: true + /@types/ws/8.5.3: + resolution: {integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==} + dependencies: + '@types/node': 17.0.41 + dev: true + /@types/yargs-parser/21.0.0: resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==} dev: true