From dfb7c2ea3ff1ffbc6ff480da56069695e7369979 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 26 Dec 2021 13:03:29 +0800 Subject: [PATCH] ci: fix testing failures caused by node_module --- .github/workflows/ci.yml | 2 ++ .../jsx-pinia-with-tests/cypress/plugins/index.js | 1 - .../cypress/plugins/index.js | 1 - .../jsx-router-with-tests/cypress/plugins/index.js | 1 - playground/jsx-with-tests/cypress/plugins/index.js | 1 - .../pinia-with-tests/cypress/plugins/index.js | 1 - .../cypress/plugins/index.js | 1 - .../router-with-tests/cypress/plugins/index.js | 1 - .../cypress/plugins/index.ts | 14 +++++--------- .../cypress/plugins/index.ts | 14 +++++--------- .../cypress/plugins/index.ts | 14 +++++--------- .../cypress/plugins/index.ts | 14 +++++--------- .../cypress/plugins/index.ts | 14 +++++--------- .../cypress/plugins/index.ts | 14 +++++--------- .../cypress/plugins/index.ts | 14 +++++--------- .../typescript-with-tests/cypress/plugins/index.ts | 14 +++++--------- playground/with-tests/cypress/plugins/index.js | 1 - utils/renderTemplate.js | 5 +++++ 18 files changed, 47 insertions(+), 80 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7981ee2d..5d9bdcb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,4 +36,6 @@ jobs: cache: 'pnpm' - run: pnpm install - run: pnpm pretest + # Rerun install to ensure the dependencies in the playground apps are resolved correctly + - run: pnpm install - run: pnpm test diff --git a/playground/jsx-pinia-with-tests/cypress/plugins/index.js b/playground/jsx-pinia-with-tests/cypress/plugins/index.js index 932b68e3..db04a79b 100644 --- a/playground/jsx-pinia-with-tests/cypress/plugins/index.js +++ b/playground/jsx-pinia-with-tests/cypress/plugins/index.js @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ /// // *********************************************************** // This example plugins/index.js can be used to load plugins diff --git a/playground/jsx-router-pinia-with-tests/cypress/plugins/index.js b/playground/jsx-router-pinia-with-tests/cypress/plugins/index.js index 932b68e3..db04a79b 100644 --- a/playground/jsx-router-pinia-with-tests/cypress/plugins/index.js +++ b/playground/jsx-router-pinia-with-tests/cypress/plugins/index.js @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ /// // *********************************************************** // This example plugins/index.js can be used to load plugins diff --git a/playground/jsx-router-with-tests/cypress/plugins/index.js b/playground/jsx-router-with-tests/cypress/plugins/index.js index 932b68e3..db04a79b 100644 --- a/playground/jsx-router-with-tests/cypress/plugins/index.js +++ b/playground/jsx-router-with-tests/cypress/plugins/index.js @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ /// // *********************************************************** // This example plugins/index.js can be used to load plugins diff --git a/playground/jsx-with-tests/cypress/plugins/index.js b/playground/jsx-with-tests/cypress/plugins/index.js index 932b68e3..db04a79b 100644 --- a/playground/jsx-with-tests/cypress/plugins/index.js +++ b/playground/jsx-with-tests/cypress/plugins/index.js @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ /// // *********************************************************** // This example plugins/index.js can be used to load plugins diff --git a/playground/pinia-with-tests/cypress/plugins/index.js b/playground/pinia-with-tests/cypress/plugins/index.js index 932b68e3..db04a79b 100644 --- a/playground/pinia-with-tests/cypress/plugins/index.js +++ b/playground/pinia-with-tests/cypress/plugins/index.js @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ /// // *********************************************************** // This example plugins/index.js can be used to load plugins diff --git a/playground/router-pinia-with-tests/cypress/plugins/index.js b/playground/router-pinia-with-tests/cypress/plugins/index.js index 932b68e3..db04a79b 100644 --- a/playground/router-pinia-with-tests/cypress/plugins/index.js +++ b/playground/router-pinia-with-tests/cypress/plugins/index.js @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ /// // *********************************************************** // This example plugins/index.js can be used to load plugins diff --git a/playground/router-with-tests/cypress/plugins/index.js b/playground/router-with-tests/cypress/plugins/index.js index 932b68e3..db04a79b 100644 --- a/playground/router-with-tests/cypress/plugins/index.js +++ b/playground/router-with-tests/cypress/plugins/index.js @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ /// // *********************************************************** // This example plugins/index.js can be used to load plugins diff --git a/playground/typescript-jsx-pinia-with-tests/cypress/plugins/index.ts b/playground/typescript-jsx-pinia-with-tests/cypress/plugins/index.ts index 932b68e3..640496ba 100644 --- a/playground/typescript-jsx-pinia-with-tests/cypress/plugins/index.ts +++ b/playground/typescript-jsx-pinia-with-tests/cypress/plugins/index.ts @@ -1,8 +1,8 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/// /// // *********************************************************** -// This example plugins/index.js can be used to load plugins +// This example plugins/index.ts can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. @@ -14,17 +14,13 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const { startDevServer } = require('@cypress/vite-dev-server') +import { startDevServer } from '@cypress/vite-dev-server' -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { +export default ((on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('dev-server:start', (options) => { return startDevServer({ options }) }) return config -} +}) as Cypress.PluginConfig diff --git a/playground/typescript-jsx-router-pinia-with-tests/cypress/plugins/index.ts b/playground/typescript-jsx-router-pinia-with-tests/cypress/plugins/index.ts index 932b68e3..640496ba 100644 --- a/playground/typescript-jsx-router-pinia-with-tests/cypress/plugins/index.ts +++ b/playground/typescript-jsx-router-pinia-with-tests/cypress/plugins/index.ts @@ -1,8 +1,8 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/// /// // *********************************************************** -// This example plugins/index.js can be used to load plugins +// This example plugins/index.ts can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. @@ -14,17 +14,13 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const { startDevServer } = require('@cypress/vite-dev-server') +import { startDevServer } from '@cypress/vite-dev-server' -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { +export default ((on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('dev-server:start', (options) => { return startDevServer({ options }) }) return config -} +}) as Cypress.PluginConfig diff --git a/playground/typescript-jsx-router-with-tests/cypress/plugins/index.ts b/playground/typescript-jsx-router-with-tests/cypress/plugins/index.ts index 932b68e3..640496ba 100644 --- a/playground/typescript-jsx-router-with-tests/cypress/plugins/index.ts +++ b/playground/typescript-jsx-router-with-tests/cypress/plugins/index.ts @@ -1,8 +1,8 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/// /// // *********************************************************** -// This example plugins/index.js can be used to load plugins +// This example plugins/index.ts can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. @@ -14,17 +14,13 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const { startDevServer } = require('@cypress/vite-dev-server') +import { startDevServer } from '@cypress/vite-dev-server' -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { +export default ((on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('dev-server:start', (options) => { return startDevServer({ options }) }) return config -} +}) as Cypress.PluginConfig diff --git a/playground/typescript-jsx-with-tests/cypress/plugins/index.ts b/playground/typescript-jsx-with-tests/cypress/plugins/index.ts index 932b68e3..640496ba 100644 --- a/playground/typescript-jsx-with-tests/cypress/plugins/index.ts +++ b/playground/typescript-jsx-with-tests/cypress/plugins/index.ts @@ -1,8 +1,8 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/// /// // *********************************************************** -// This example plugins/index.js can be used to load plugins +// This example plugins/index.ts can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. @@ -14,17 +14,13 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const { startDevServer } = require('@cypress/vite-dev-server') +import { startDevServer } from '@cypress/vite-dev-server' -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { +export default ((on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('dev-server:start', (options) => { return startDevServer({ options }) }) return config -} +}) as Cypress.PluginConfig diff --git a/playground/typescript-pinia-with-tests/cypress/plugins/index.ts b/playground/typescript-pinia-with-tests/cypress/plugins/index.ts index 932b68e3..640496ba 100644 --- a/playground/typescript-pinia-with-tests/cypress/plugins/index.ts +++ b/playground/typescript-pinia-with-tests/cypress/plugins/index.ts @@ -1,8 +1,8 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/// /// // *********************************************************** -// This example plugins/index.js can be used to load plugins +// This example plugins/index.ts can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. @@ -14,17 +14,13 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const { startDevServer } = require('@cypress/vite-dev-server') +import { startDevServer } from '@cypress/vite-dev-server' -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { +export default ((on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('dev-server:start', (options) => { return startDevServer({ options }) }) return config -} +}) as Cypress.PluginConfig diff --git a/playground/typescript-router-pinia-with-tests/cypress/plugins/index.ts b/playground/typescript-router-pinia-with-tests/cypress/plugins/index.ts index 932b68e3..640496ba 100644 --- a/playground/typescript-router-pinia-with-tests/cypress/plugins/index.ts +++ b/playground/typescript-router-pinia-with-tests/cypress/plugins/index.ts @@ -1,8 +1,8 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/// /// // *********************************************************** -// This example plugins/index.js can be used to load plugins +// This example plugins/index.ts can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. @@ -14,17 +14,13 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const { startDevServer } = require('@cypress/vite-dev-server') +import { startDevServer } from '@cypress/vite-dev-server' -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { +export default ((on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('dev-server:start', (options) => { return startDevServer({ options }) }) return config -} +}) as Cypress.PluginConfig diff --git a/playground/typescript-router-with-tests/cypress/plugins/index.ts b/playground/typescript-router-with-tests/cypress/plugins/index.ts index 932b68e3..640496ba 100644 --- a/playground/typescript-router-with-tests/cypress/plugins/index.ts +++ b/playground/typescript-router-with-tests/cypress/plugins/index.ts @@ -1,8 +1,8 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/// /// // *********************************************************** -// This example plugins/index.js can be used to load plugins +// This example plugins/index.ts can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. @@ -14,17 +14,13 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const { startDevServer } = require('@cypress/vite-dev-server') +import { startDevServer } from '@cypress/vite-dev-server' -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { +export default ((on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('dev-server:start', (options) => { return startDevServer({ options }) }) return config -} +}) as Cypress.PluginConfig diff --git a/playground/typescript-with-tests/cypress/plugins/index.ts b/playground/typescript-with-tests/cypress/plugins/index.ts index 932b68e3..640496ba 100644 --- a/playground/typescript-with-tests/cypress/plugins/index.ts +++ b/playground/typescript-with-tests/cypress/plugins/index.ts @@ -1,8 +1,8 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/// /// // *********************************************************** -// This example plugins/index.js can be used to load plugins +// This example plugins/index.ts can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. @@ -14,17 +14,13 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const { startDevServer } = require('@cypress/vite-dev-server') +import { startDevServer } from '@cypress/vite-dev-server' -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { +export default ((on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('dev-server:start', (options) => { return startDevServer({ options }) }) return config -} +}) as Cypress.PluginConfig diff --git a/playground/with-tests/cypress/plugins/index.js b/playground/with-tests/cypress/plugins/index.js index 932b68e3..db04a79b 100644 --- a/playground/with-tests/cypress/plugins/index.js +++ b/playground/with-tests/cypress/plugins/index.js @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable @typescript-eslint/no-var-requires */ /// // *********************************************************** // This example plugins/index.js can be used to load plugins diff --git a/utils/renderTemplate.js b/utils/renderTemplate.js index 3423f3a1..9d7c7070 100644 --- a/utils/renderTemplate.js +++ b/utils/renderTemplate.js @@ -17,6 +17,11 @@ function renderTemplate(src, dest) { const stats = fs.statSync(src) if (stats.isDirectory()) { + // skip node_module + if (path.basename(src) === 'node_modules') { + return + } + // if it's a directory, render its subdirectories and files recursively fs.mkdirSync(dest, { recursive: true }) for (const file of fs.readdirSync(src)) { -- 2.39.5