Skip to content
This repository has been archived by the owner on Dec 30, 2019. It is now read-only.

E2E tests in ts #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@
}
},
"lint-staged": {
"*.ts": [
"src/**/*.ts": [
"vue-cli-service lint --fix",
"prettier --write",
"git add"
],
"*.vue": [
"src/**/*.vue": [
"vue-cli-service lint --fix",
"stylelint",
"prettier --write",
Expand Down
20 changes: 20 additions & 0 deletions tests/e2e/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
// https://docs.cypress.io/guides/guides/plugins-guide.html
/* eslint-disable import/no-extraneous-dependencies global-require */
const webpack = require("@cypress/webpack-preprocessor");

module.exports = (on, config) => {
on("file:preprocessor", webpack({
webpackOptions: {
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: { transpileOnly: false }
}
]
}
},
watchOptions: {}
}));

return Object.assign({}, config, {
fixturesFolder: "tests/e2e/fixtures",
integrationFolder: "tests/e2e/specs",
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/specs/test.js → tests/e2e/specs/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// https://docs.cypress.io/api/introduction/api.html
/// <reference types="cypress"/>

describe("My First Test", () => {
it("Visits the app root url", () => {
Expand Down
11 changes: 11 additions & 0 deletions tests/e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"baseUrl": " ../../node_modules",
"types": ["cypress"]
},
"include": [
"**/*.ts"
]
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"exclude": [
"node_modules",
"build"
"build",
"tests/e2e"
]
}
22 changes: 12 additions & 10 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ module.exports = {
.when(process.env.NODE_ENV === "production", config => {
// Use a runtime chunk to optimize cache busting.
// Otherwise, the runtime information would be added to the entry point.
config
.optimization
.runtimeChunk({ name: "runtime" });
if (!process.env.CYPRESS_ENV) {
config
.optimization
.runtimeChunk({ name: "runtime" });
}

// Configure path alias for rxjs.
const rxPaths = require("rxjs/_esm2015/path-mapping");
const rxResolvedPaths = rxPaths();
for (const p in rxResolvedPaths) {
if (rxResolvedPaths.hasOwnProperty(p)) {
config.resolve.alias.set(p, rxResolvedPaths[p]);
}
// Configure path alias for rxjs.
const rxPaths = require("rxjs/_esm2015/path-mapping");
const rxResolvedPaths = rxPaths();
for (const p in rxResolvedPaths) {
if (rxResolvedPaths.hasOwnProperty(p)) {
config.resolve.alias.set(p, rxResolvedPaths[p]);
}
}

// Configure style purging.
const purgeOptions = {
Expand Down