-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli-plugin-e2e-cypress typescript support #1350
Comments
look forward for this feature. I'm new to vue(or even the frontend eco), PS: @vue/cli 3.0 is awesome. (with it,I dont' have to waste time on config webpack, it's too difficult) |
Actually you just need to put a
Of course change your |
This did not work for me. The This instead causes type definition conflicts with jest, similar to the problem explained here. In the end i modified the I'm not sure if this solution is considered a best practice though.... |
Adding a tsconfig.json (to tests/e2e) of any kind (even total garbage) seems to have no effect on my project whatsover. Cypress complains about |
@peabnuts123 I think and here is the content of Update: All my spec are in ts, but the files you can see must remain in js (by "must" I meant that I try to move them to ts and then it doesn't work) |
I ran into issues with the out of the box solution vue-cli provides, a custom webpack config for ts compilation for cypress solved these issues. Check out this repo if you want a working solution.
|
I've tried the workaround suggested by @iskanderbroere: While the tests are executed fine, the build step before causes a lot of type checking errors complaining about duplicated and errornous type declarations involving €dit#2: Using the
Not sure why this file is picked up, since it is not part of the root project anymore. Using the "regular" |
I'm experiencing the same issue as @peabnuts123 where my tsconfig.json in the e2e folder is ignored. Is there any known workaround for that anyone can point me toward? |
Same as @albernhagen @peabnuts123 , any known workaround? |
I will add this code in vue.config.js chainWebpack: config => {
const options = JSON.parse(process.env.npm_config_argv).original
if (options.some((el) => el.includes('e2e'))) {
config
.plugin('fork-ts-checker')
.tap(args => {
args[0].tsconfig = path.resolve(process.env.PWD, './tests/e2e/tsconfig.json')
return args
})
if (options.some((el) => el.includes('headless'))) {
config.plugins.delete('fork-ts-checker')
}
}
} tests/e2e/tsconfig.json {
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": [
"cypress",
"webpack",
"webpack-env"
],
"skipLibCheck": true
},
"include": [
"../../src/**/*.ts",
"../../src/**/*.tsx",
"../../src/**/*.vue",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"../unit/**/*.ts"
]
} Because:
|
I did have some problems using the scaffolded, commented out code in the plugins file, but I did have some luck setting up typescript for both specs and commands with the use of the preprocessor from this repo along with the tests/e2e/tsconfig recommendations mentioned here. You'll need to install // tests/e2e/plugins/cy-ts-preprocessor.js
const webpack = require("@cypress/webpack-preprocessor");
const webpackOptions = {
resolve: {
extensions: [".ts", ".js"],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: "ts-loader",
},
],
},
],
},
};
const options = {
webpackOptions,
};
module.exports = webpack(options); // tests/e2e/plugins/index.js
const cypressTypeScriptPreprocessor = require("./cy-ts-preprocessor");
module.exports = (on, config) => {
// on('file:preprocessor', webpack({
// webpackOptions: require('@vue/cli-service/webpack.config'),
// watchOptions: {}
// }))
on("file:preprocessor", cypressTypeScriptPreprocessor);
return Object.assign({}, config, {
fixturesFolder: "tests/e2e/fixtures",
integrationFolder: "tests/e2e/specs",
screenshotsFolder: "tests/e2e/screenshots",
videosFolder: "tests/e2e/videos",
supportFile: "tests/e2e/support/index.ts", // If you want typescript commands, change the extention
});
} // tests/e2e/tsconfig.json
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"strict": true,
"baseUrl": "../../.", // changed to mimic root tsconfig baseUrl
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
},
"include": ["**/*.ts"]
} Hope this is of use to someone else. Elaborating on the default preprocessor not working: It seems that when using that, you cannot use any custom commands, either from plugins, or created in your project. |
Hi, I upgraded vue-cli to latest version 4.5.11, so it looks like this:
changed test.js to test.ts |
Add e2e tests with cypress using `vue add e2e-cypress`. Vue CLI does not support creating typescript tests at this moment (vuejs/vue-cli#1350).
Add e2e tests with cypress using `vue add e2e-cypress`. Vue CLI does not support creating typescript tests at this moment (vuejs/vue-cli#1350).
Add e2e tests with cypress using `vue add e2e-cypress`. Vue CLI does not support creating typescript tests at this moment (vuejs/vue-cli#1350).
Add e2e tests with cypress using `vue add e2e-cypress`. Vue CLI does not support creating typescript tests at this moment (vuejs/vue-cli#1350).
Add e2e tests with cypress using `vue add e2e-cypress`. Vue CLI does not support creating typescript tests at this moment (vuejs/vue-cli#1350).
Add e2e tests with cypress using `vue add e2e-cypress`. Vue CLI does not support creating typescript tests at this moment (vuejs/vue-cli#1350).
What problem does this feature solve?
Since Cypress already ships with official Typescript declarations, it would be nice to support Typescript for the e2e tests via cue-cli.
For the end user experience, I would expect the e2e tests to be .ts files by default when creating a vue-cli project with Typescript support and Cypress e2e testing.
What does the proposed API look like?
On the background, I would expect two things when creating a vue-cli project with Typescript support and Cypress e2e testing:
It should create the tests as .ts files and automatically configure Typescript for the e2e folder as described in: https://docs.cypress.io/guides/tooling/typescript-support.html
When starting the tests via vue-cli-service test:e2e it should watch and transpile the .ts test files similar to: https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/preprocessors__typescript-webpack
The text was updated successfully, but these errors were encountered: