Skip to content

Commit

Permalink
add ts support for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
UnnamedXAer committed Nov 8, 2021
1 parent a4da475 commit ce5ee75
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"vuex": "^4.0.0-0"
},
"devDependencies": {
"@cypress/webpack-preprocessor": "^5.9.1",
"@types/chai": "^4.2.11",
"@types/chai-spies": "^1.0.3",
"@types/mocha": "^5.2.4",
Expand Down
27 changes: 27 additions & 0 deletions tests/e2e/plugins/cy-ts-preprocessor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
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);
19 changes: 14 additions & 5 deletions tests/e2e/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@
// https://docs.cypress.io/api/plugins/preprocessors-api.html#Examples

// /* eslint-disable import/no-extraneous-dependencies, global-require */
// const webpack = require('@cypress/webpack-preprocessor')
// eslint-disable-next-line @typescript-eslint/no-var-requires
// const webpack = require("@cypress/webpack-preprocessor");

// eslint-disable-next-line @typescript-eslint/no-var-requires
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",
// webpack({
// webpackOptions: require("@vue/cli-service/webpack.config"),
// watchOptions: {},
// })
// );

on("file:preprocessor", cypressTypeScriptPreprocessor);

return Object.assign({}, config, {
fixturesFolder: "tests/e2e/fixtures",
Expand Down
23 changes: 23 additions & 0 deletions tests/e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": [
"cypress",
"webpack",
"webpack-env",
"mocha",
"chai"
],
"skipLibCheck": true
},
"include": [
"../../src/**/*.ts",
"../../src/**/*.tsx",
"../../src/**/*.vue",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"../unit/**/*.ts"
]
}
25 changes: 17 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,15 @@
date-fns "^1.27.2"
figures "^1.7.0"

"@cypress/webpack-preprocessor@^5.9.1":
version "5.9.1"
resolved "https://registry.yarnpkg.com/@cypress/webpack-preprocessor/-/webpack-preprocessor-5.9.1.tgz#2694aa832baf3984d90bcb899e1ecff377560904"
integrity sha512-cg1ikftIo7NdlRA8ocNSxWjHJlh1JlTkN9ZfXUuKWWcJgrEdYLjXk0UzY6gYbLLaFka4oIhN6SvL5Y/7iELvgg==
dependencies:
bluebird "^3.7.1"
debug "4.3.2"
lodash "^4.17.20"

"@cypress/xvfb@1.2.4":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@cypress/xvfb/-/xvfb-1.2.4.tgz#2daf42e8275b39f4aa53c14214e557bd14e7748a"
Expand Down Expand Up @@ -2435,7 +2444,7 @@ bluebird@3.5.0:
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c"
integrity sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=

bluebird@^3.1.1, bluebird@^3.5.5:
bluebird@^3.1.1, bluebird@^3.5.5, bluebird@^3.7.1:
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
Expand Down Expand Up @@ -3642,20 +3651,20 @@ debug@3.2.6:
dependencies:
ms "^2.1.1"

debug@4.3.2, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1:
version "4.3.2"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
dependencies:
ms "2.1.2"

debug@^3.1.0, debug@^3.1.1, debug@^3.2.6:
version "3.2.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==
dependencies:
ms "^2.1.1"

debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1:
version "4.3.2"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
dependencies:
ms "2.1.2"

decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
Expand Down

0 comments on commit ce5ee75

Please sign in to comment.