-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create-cypress-tests installation wizard (#9563)
* Remove unused stuff * Fix eslint errors * Use local cypress running script * Fix dependency resolution * Revert "Fix dependency resolution" This reverts commit 01a70be. * Add @cypress/react CI * Properly resolve @types pacakges * Run tests with mocha * Fix cypress tests * Fix or skip some specs * Add retries to the card-spec.js * Remove jest mocks * Run e2e examples on CI * Fix yarn cache key * Fix e2e examples jobs * Rename cypress-react-unit-test with @cypress/react * Fix circleci.yml * Revert "Fix e2e examples jobs" This reverts commit efcc7c4. * Revert " Rename cypress-react-unit-test with @cypress/react" This reverts commit 4febfcc. * Replce cypress-react-unit-test with @cypress/react * Persist build artifacts * Fix working directory paths circle.yml * Fix more CI * adding yarn.lock files * Make package.json for folder * Remove .npmrc * Update circle.yml * Remove unused files * Copy plugins files to the "dist" folder * Fix links to the github repos * Move init wizard from npm/react/init to npm/wizard * Move init wizard from npm/react/init to npm/wizard * Implement initial vue template * Run wizard tests on CI * Refactor continue: bool to success: bool for better code readability * Fix circleci.yml * Use only absolute paths for tests * Stub process.exit calls * Remove useless comments * Add installation cypress to the wizard logic * More improvements * Include packages/examples/cypress into git * Commit new files * Use packages/example as SST for generated files * Last improvements for wizard * Update packages/server/lib/scaffold.js * Rename wizard to create-cypress-tests * Fix circleci config * Fix snapshot tests * Run all create-cypress-tests on ci * Do not install plugins and scaffold files from kitchensink * Ignore integration/examples folder for packages/example * Run create-cypress-tests-tests on CI * Add copy example cross-platform script * Use copy example script in tests * feat: create-cypress-tests auto-inject config (#9116) * Implement the basic babel code transformation for configs * Add more tests for edge-cases * Add snapshot tests for autogenerated code for each template * Add git status guard * Add git status guard * Fix last test * Fix tests * Revert changes for packages/example * Revert changes for packages/example/tsconfig.json * Prepeare package for the release * Fix inquirer name * v0.0.125 * v0.0.127 * v0.0.128 * v0.0.130 * v0.0.131 * Add more UX features * Add vue-cli template * Make src as default folder for vue-cli template * Revert dev-time changes * Run appveyour windows build * Run full appveyour build * Fix circle.yml * Update plugins * Join paths for windows * Revert example/lib changes * Fix tests * Revert unnecessary changes * Implement dev-server dependency installation * Update npm/create-cypress-tests/README.md * Include webpack-options template in dist Co-authored-by: Jessica Sachs <jess@jessicasachs.io>
- Loading branch information
1 parent
cce08d2
commit c405ee8
Showing
77 changed files
with
3,384 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"plugins": [ | ||
"cypress", | ||
"@cypress/dev" | ||
], | ||
"extends": [ | ||
"plugin:@cypress/dev/general", | ||
"plugin:@cypress/dev/tests" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"env": { | ||
"cypress/globals": true | ||
}, | ||
"rules": { | ||
"no-console": "off", | ||
"mocha/no-global-tests": "off", | ||
"@typescript-eslint/no-unused-vars": "off" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"lib/*" | ||
], | ||
"rules": { | ||
"no-console": 1 | ||
} | ||
}, | ||
{ | ||
"files": [ | ||
"**/*.json" | ||
], | ||
"rules": { | ||
"quotes": "off", | ||
"comma-dangle": "off" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"watch-ignore": [ | ||
"node_modules" | ||
], | ||
"require": "ts-node/register", | ||
"exit": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
./src/ | ||
./initial-template/ | ||
scripts/ | ||
__snapshots__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Create Cypress Tests | ||
|
||
Installs and injects all the required configuration to run cypress tests. | ||
|
||
## Quick overview | ||
|
||
``` | ||
cd my-app | ||
npx create-cypress-test | ||
npx cypress open | ||
``` | ||
|
||
![demo](./demo.gif) | ||
|
||
## Package manager | ||
|
||
This wizard will automatically determine which package do you use. If `yarn` available as global dependency it will use yarn to install dependencies and create lock file. | ||
|
||
If you need to use `npm` over `yarn` you can do the following | ||
|
||
``` | ||
npx create-cypress-tests --use-npm | ||
``` | ||
|
||
By the way you can use yarn to run the installation wizard 😉 | ||
|
||
``` | ||
yarn create cypress-tests | ||
``` | ||
|
||
## Typescript | ||
|
||
This package will also automatically determine if typescript if available in this project and inject the required typescript configuration for cypress. If you are starting a new project and want to create typescript configuration, please do the following: | ||
|
||
``` | ||
npm init | ||
npm install typescript | ||
npx create-cypress-tests | ||
``` | ||
|
||
## Configuration | ||
|
||
Here is a list of available configuration options: | ||
|
||
`--use-npm` – use npm if yarn available | ||
`--ignore-typescript` – will not create typescript configuration if available | ||
`--ignore-examples` – will create a 1 empty spec file (`cypress/integration/spec.js`) to start with | ||
`--component-tests` – will not ask should setup component testing or not | ||
|
||
## License | ||
|
||
The project is licensed under the terms of [MIT license](../../LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
exports['babel installation template correctly generates plugins config 1'] = ` | ||
const preprocessor = require('@cypress/react/plugins/babel'); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` |
50 changes: 50 additions & 0 deletions
50
npm/create-cypress-tests/__snapshots__/init-component-testing.test.ts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
exports['Injects guessed next.js template cypress.json'] = ` | ||
const preprocessor = require("@cypress/react/plugins/next"); | ||
module.exports = (on, config) => { | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` | ||
|
||
exports['Injects guessed next.js template plugins/index.js'] = ` | ||
const preprocessor = require("@cypress/react/plugins/next"); | ||
module.exports = (on, config) => { | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` | ||
|
||
exports['Injects guessed next.js template support/index.js'] = ` | ||
import "@cypress/react/support"; | ||
` | ||
|
||
exports['Injected overridden webpack template cypress.json'] = ` | ||
const preprocessor = require("@cypress/react/plugins/react-scripts"); | ||
module.exports = (on, config) => { | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` | ||
|
||
exports['Injected overridden webpack template plugins/index.js'] = ` | ||
const preprocessor = require("@cypress/react/plugins/react-scripts"); | ||
module.exports = (on, config) => { | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` | ||
|
||
exports['Injected overridden webpack template support/index.js'] = ` | ||
import "./commands.js"; | ||
import "@cypress/react/support"; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
exports['next.js install template correctly generates plugins config 1'] = ` | ||
const preprocessor = require('@cypress/react/plugins/next'); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` |
10 changes: 10 additions & 0 deletions
10
npm/create-cypress-tests/__snapshots__/react-scripts.test.ts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
exports['create-react-app install template correctly generates plugins config 1'] = ` | ||
const preprocessor = require('@cypress/react/plugins/react-scripts'); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` |
24 changes: 24 additions & 0 deletions
24
npm/create-cypress-tests/__snapshots__/reactWebpackFile.test.ts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
exports['webpack-file install template correctly generates plugins config when webpack config path is missing 1'] = ` | ||
const preprocessor = require("@cypress/react/plugins/load-webpack"); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
// TODO replace with valid webpack config path | ||
config.env.webpackFilename = './webpack.config.js'; | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` | ||
|
||
exports['webpack-file install template correctly generates plugins config when webpack config path is provided 1'] = ` | ||
const preprocessor = require("@cypress/react/plugins/load-webpack"); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
config.env.webpackFilename = 'config/webpack.config.js'; | ||
preprocessor(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
exports['rollup-file install template correctly generates plugins config when webpack config path is missing 1'] = ` | ||
const rollupPreprocessor = require("@bahmutov/cy-rollup"); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
on('file:preprocessor', rollupPreprocessor({ | ||
// TODO replace with valid rollup config path | ||
configFile: 'rollup.config.js' | ||
})); | ||
require('@cypress/code-coverage/task')(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` | ||
|
||
exports['rollup-file install template correctly generates plugins config when webpack config path is provided 1'] = ` | ||
const rollupPreprocessor = require("@bahmutov/cy-rollup"); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
on('file:preprocessor', rollupPreprocessor({ | ||
configFile: 'config/rollup.config.js' | ||
})); | ||
require('@cypress/code-coverage/task')(on, config); | ||
return config; // IMPORTANT to return the config object | ||
}; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
exports['vue webpack-file install template correctly generates plugins for vue-cli-service 1'] = ` | ||
const preprocessor = require("@cypress/vue/dist/plugins/webpack"); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
preprocessor(on, config); // IMPORTANT return the config object | ||
return config; | ||
}; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
exports['vue: vite template correctly generates plugins config 1'] = ` | ||
const { | ||
startDevServer | ||
} = require("@cypress/vite-dev-server"); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
on("dev-server:start", async options => startDevServer({ | ||
options | ||
})); | ||
}; | ||
` |
24 changes: 24 additions & 0 deletions
24
npm/create-cypress-tests/__snapshots__/vueWebpackFile.test.ts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
exports['vue webpack-file install template correctly generates plugins config when webpack config path is missing 1'] = ` | ||
const { | ||
onFilePreprocessor | ||
} = require('@cypress/vue/dist/preprocessor/webpack'); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
// TODO replace with valid webpack config path | ||
on('file:preprocessor', onFilePreprocessor('./webpack.config.js')); | ||
}; | ||
` | ||
|
||
exports['vue webpack-file install template correctly generates plugins config when webpack config path is provided 1'] = ` | ||
const { | ||
onFilePreprocessor | ||
} = require('@cypress/vue/dist/preprocessor/webpack'); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
on('file:preprocessor', onFilePreprocessor('build/webpack.config.js')); | ||
}; | ||
` |
34 changes: 34 additions & 0 deletions
34
npm/create-cypress-tests/__snapshots__/webpackOptions.test.ts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
exports['webpack-options template correctly generates plugins config 1'] = ` | ||
const webpackPreprocessor = require("@cypress/webpack-preprocessor"); | ||
const something = require("something"); | ||
module.exports = (on, config) => { | ||
/** @type import("webpack").Configuration */ | ||
const webpackConfig = { | ||
resolve: { | ||
extensions: ['.js', '.ts', '.jsx', '.tsx'] | ||
}, | ||
mode: 'development', | ||
devtool: false, | ||
output: { | ||
publicPath: '/', | ||
chunkFilename: '[name].bundle.js' | ||
}, | ||
// TODO: update with valid configuration for your app | ||
module: { | ||
rules: [{ | ||
test: /\\.(js|jsx|mjs|ts|tsx)$/, | ||
loader: 'babel-loader', | ||
options: { ...babelConfig, | ||
cacheDirectory: path.resolve(__dirname, '..', '..', '.babel-cache') | ||
} | ||
}] | ||
} | ||
}; | ||
on('dev-server:start', options => startDevServer({ | ||
options, | ||
webpackConfig | ||
})); | ||
}; | ||
` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
c405ee8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
c405ee8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
c405ee8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 ia32
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
c405ee8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: