Skip to content

Commit

Permalink
quasarframework#227: Webpack code coverage support
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrombitas committed Jun 23, 2022
1 parent 06557ce commit a695667
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/e2e-cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"@cypress/vite-dev-server": "^2.2.2",
"@cypress/vue": "^3.1.0",
"@cypress/webpack-dev-server": "^1.8.3",
"@cypress/webpack-preprocessor": "^5.12.0",
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
"cross-env": "^7.0.3",
"cypress": "^9.5.2",
"lodash": "^4.17.21",
Expand Down
19 changes: 15 additions & 4 deletions packages/e2e-cypress/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,21 @@ module.exports = async function (api) {
);
});
} else {
// TODO: add webpack code coverage support
// See https://www.npmjs.com/package/istanbul-instrumenter-loader
// https://github.com/vuejs/vue-cli/issues/1363#issuecomment-405352542
// https://github.com/akoidan/vue-webpack-typescript
if (api.hasWebpack === true) {
api.extendWebpack((cfg, { isClient, isServer }, api) => {
cfg.module.rules.push({
test: /\.(js|ts|vue)$/,
loader: '@jsdevtools/coverage-istanbul-loader',
options: { esModules: true },
enforce: 'post',
include: require('path').join(__dirname, 'src'),
exclude: [
/\.(e2e|spec)\.(js|ts)$/,
/node_modules/,
]
});
});
}
}
}
};
2 changes: 1 addition & 1 deletion test-project-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
}
}
}
5 changes: 3 additions & 2 deletions test-project-webpack/quasar.extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"@quasar/testing-e2e-cypress": {
"options": [
"scripts",
"typescript"
"typescript",
"code-coverage"
]
}
}
}
26 changes: 26 additions & 0 deletions test-project-webpack/test/cypress/plugins/cy-ts-preprocessor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import preProcessor from '@cypress/webpack-preprocessor';

const webpackOptions = {
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: 'ts-loader'
}
]
}
]
}
};

const options = {
webpackOptions
};

export default preProcessor(options);
5 changes: 4 additions & 1 deletion test-project-webpack/test/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
// the project's config changing)

import { injectDevServer } from '@quasar/quasar-app-extension-testing-e2e-cypress/cct-dev-server';
import cyTsPreprocessor from "./cy-ts-preprocessor";


const pluginConfig: Cypress.PluginConfig = async (on, config) => {

on('file:preprocessor', cyTsPreprocessor);

require('@cypress/code-coverage/task')(on, config);
// Enable component testing, you can safely remove this
// if you don't plan to use Cypress for component tests
if (config.testingType === 'component') {
Expand Down
1 change: 1 addition & 0 deletions test-project-webpack/test/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
// ***********************************************************

import './commands';
import '@cypress/code-coverage/support';
9 changes: 9 additions & 0 deletions test-project-webpack/test/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"],
"esModuleInterop": true
},
"include": ["**/*.ts"]
}
31 changes: 30 additions & 1 deletion test-project-webpack/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,15 @@
debug "^4.3.2"
lodash "^4.17.20"

"@cypress/webpack-preprocessor@^5.12.0":
version "5.12.0"
resolved "https://registry.yarnpkg.com/@cypress/webpack-preprocessor/-/webpack-preprocessor-5.12.0.tgz#231f6c86423237e17eaf12ce6193d4b67290b852"
integrity sha512-D/eLKKlgx6c/307FaCmjZGjFA64G29aA8KcCy6WqpNK/bSnRdPquMW2plemIsT/B80TK2DDKzZX/H3FcS41ZDA==
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 @@ -1409,6 +1418,17 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"

"@jsdevtools/coverage-istanbul-loader@^3.0.5":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@jsdevtools/coverage-istanbul-loader/-/coverage-istanbul-loader-3.0.5.tgz#2a4bc65d0271df8d4435982db4af35d81754ee26"
integrity sha512-EUCPEkaRPvmHjWAAZkWMT7JDzpw7FKB00WTISaiXsbNOd5hCHg77XLA8sLYLFDo1zepYLo2w7GstN8YBqRXZfA==
dependencies:
convert-source-map "^1.7.0"
istanbul-lib-instrument "^4.0.3"
loader-utils "^2.0.0"
merge-source-map "^1.1.0"
schema-utils "^2.7.0"

"@leichtgewicht/ip-codec@^2.0.1":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"
Expand Down Expand Up @@ -1559,6 +1579,8 @@
"@cypress/vite-dev-server" "^2.2.2"
"@cypress/vue" "^3.1.0"
"@cypress/webpack-dev-server" "^1.8.3"
"@cypress/webpack-preprocessor" "^5.12.0"
"@jsdevtools/coverage-istanbul-loader" "^3.0.5"
cross-env "^7.0.3"
cypress "^9.5.2"
lodash "^4.17.21"
Expand Down Expand Up @@ -6765,6 +6787,13 @@ [email protected]:
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=

merge-source-map@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.1.0.tgz#2fdde7e6020939f70906a68f2d7ae685e4c8c646"
integrity sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==
dependencies:
source-map "^0.6.1"

merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
Expand Down Expand Up @@ -8392,7 +8421,7 @@ [email protected]:
ajv "^6.12.2"
ajv-keywords "^3.4.1"

schema-utils@^2.6.5:
schema-utils@^2.6.5, schema-utils@^2.7.0:
version "2.7.1"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"
integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==
Expand Down
62 changes: 61 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,15 @@
semver "^7.3.4"
webpack-merge "^5.4.0"

"@cypress/webpack-preprocessor@^5.12.0":
version "5.12.0"
resolved "https://registry.yarnpkg.com/@cypress/webpack-preprocessor/-/webpack-preprocessor-5.12.0.tgz#231f6c86423237e17eaf12ce6193d4b67290b852"
integrity sha512-D/eLKKlgx6c/307FaCmjZGjFA64G29aA8KcCy6WqpNK/bSnRdPquMW2plemIsT/B80TK2DDKzZX/H3FcS41ZDA==
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 @@ -1576,6 +1585,17 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"

"@jsdevtools/coverage-istanbul-loader@^3.0.5":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@jsdevtools/coverage-istanbul-loader/-/coverage-istanbul-loader-3.0.5.tgz#2a4bc65d0271df8d4435982db4af35d81754ee26"
integrity sha512-EUCPEkaRPvmHjWAAZkWMT7JDzpw7FKB00WTISaiXsbNOd5hCHg77XLA8sLYLFDo1zepYLo2w7GstN8YBqRXZfA==
dependencies:
convert-source-map "^1.7.0"
istanbul-lib-instrument "^4.0.3"
loader-utils "^2.0.0"
merge-source-map "^1.1.0"
schema-utils "^2.7.0"

"@lerna/[email protected]":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@lerna/add/-/add-4.0.0.tgz#c36f57d132502a57b9e7058d1548b7a565ef183f"
Expand Down Expand Up @@ -2539,6 +2559,11 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/json-schema@^7.0.5":
version "7.0.11"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==

"@types/json-schema@^7.0.9":
version "7.0.9"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
Expand Down Expand Up @@ -2909,6 +2934,11 @@ aggregate-error@^3.0.0:
clean-stack "^2.0.0"
indent-string "^4.0.0"

ajv-keywords@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==

ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
Expand Down Expand Up @@ -3349,6 +3379,11 @@ blob-util@^2.0.2:
resolved "https://registry.yarnpkg.com/blob-util/-/blob-util-2.0.2.tgz#3b4e3c281111bb7f11128518006cdc60b403a1eb"
integrity sha512-T7JQa+zsXXEa6/8ZhHcQEW1UFfVM49Ts65uBkFL6fz2QmrElqmbajIDJvuA0tEhRe5eIjpV9ZF+0RfZR9voJFQ==

[email protected]:
version "3.7.1"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.1.tgz#df70e302b471d7473489acf26a93d63b53f874de"
integrity sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg==

[email protected], bluebird@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
Expand Down Expand Up @@ -7813,6 +7848,15 @@ loader-utils@^1.2.3:
emojis-list "^3.0.0"
json5 "^1.0.1"

loader-utils@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.2.tgz#d6e3b4fb81870721ae4e0868ab11dd638368c129"
integrity sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==
dependencies:
big.js "^5.2.2"
emojis-list "^3.0.0"
json5 "^2.1.2"

locate-path@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"
Expand Down Expand Up @@ -7928,7 +7972,7 @@ lodash.truncate@^4.4.2:
resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=

[email protected], lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.3.0, lodash@^4.7.0:
[email protected], lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.3.0, lodash@^4.7.0:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down Expand Up @@ -8127,6 +8171,13 @@ meow@^8.0.0:
type-fest "^0.18.0"
yargs-parser "^20.2.3"

merge-source-map@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.1.0.tgz#2fdde7e6020939f70906a68f2d7ae685e4c8c646"
integrity sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==
dependencies:
source-map "^0.6.1"

merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
Expand Down Expand Up @@ -10115,6 +10166,15 @@ saxes@^5.0.1:
dependencies:
xmlchars "^2.2.0"

schema-utils@^2.7.0:
version "2.7.1"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"
integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==
dependencies:
"@types/json-schema" "^7.0.5"
ajv "^6.12.4"
ajv-keywords "^3.5.2"

semver-diff@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36"
Expand Down

0 comments on commit a695667

Please sign in to comment.