Skip to content

Commit

Permalink
move mock to test
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Dec 20, 2023
1 parent 6d2ff91 commit fb39c30
Show file tree
Hide file tree
Showing 33 changed files with 50 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
/package-lock.json
/lib/packages
/docs/*/.cache
/mock/*/dist
/test/mock/*/dist
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ await coverageReport.add(coverageData2);
const coverageResults = await coverageReport.generate();
console.log(coverageResults.summary);
```
- [example v8](https://github.com/cenfun/monocart-coverage-reports/blob/main/tests/test-v8.js)
- [example istanbul](https://github.com/cenfun/monocart-coverage-reports/blob/main/tests/test-istanbul.js)
- [example v8](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-v8.js)
- [example istanbul](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-istanbul.js)

## Default Options
- [lib/default/options.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/lib/default/options.js)
Expand Down Expand Up @@ -111,13 +111,13 @@ console.log(coverageResults.summary);

## Compare Workflows
- Istanbul Workflows
- 1, Only for source code: instrumenting code with [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul),see [webpack.config-istanbul.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/mock/webpack.config-istanbul.js), or using [nyc](https://github.com/istanbuljs/nyc).
- 2, Collecting coverage data from browser `window.__coverage__`, see [example](https://github.com/cenfun/monocart-coverage-reports/blob/main/tests/test-istanbul.js).
- 1, Only for source code: instrumenting code with [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul),see [webpack.config-istanbul.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/webpack.config-istanbul.js), or using [nyc](https://github.com/istanbuljs/nyc).
- 2, Collecting coverage data from browser `window.__coverage__`, see [example](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-istanbul.js).
- 3, Generating coverage report.

- V8 Workflows
- 1, For any runtime code: nothing to do. For source code: building code with `development` [mode](https://webpack.js.org/configuration/mode/) and [sourcemap](https://webpack.js.org/configuration/devtool/) support, see [webpack.config-v8.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/mock/webpack.config-v8.js).
- 2, Collecting coverage data with [Chromium Coverage API](#chromium-coverage-api), see [example](https://github.com/cenfun/monocart-coverage-reports/blob/main/tests/test-v8.js).
- 1, For any runtime code: nothing to do. For source code: building code with `development` [mode](https://webpack.js.org/configuration/mode/) and [sourcemap](https://webpack.js.org/configuration/devtool/) support, see [webpack.config-v8.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/webpack.config-v8.js).
- 2, Collecting coverage data with [Chromium Coverage API](#chromium-coverage-api), see [example](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-v8.js).
- 3, Generating coverage report.

## Chromium Coverage API
Expand Down
30 changes: 10 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
},
"types": "./lib/index.d.ts",
"scripts": {
"build-mock": "npm run build-istanbul && npm run build-v8",
"build-istanbul": "npx webpack --config mock/webpack.config-istanbul.js",
"build-v8": "npx webpack --config mock/webpack.config-v8.js",
"test": "node ./tests/test.js && npm run build-docs",
"build": "sf lint && sf b -p && npm run build-docs",
"dev": "sf d v8",
"build-docs": "node ./scripts/build-docs.js",
"build-test": "npm run build-istanbul && npm run build-v8",
"build-istanbul": "npx webpack --config test/webpack.config-istanbul.js",
"build-v8": "npx webpack --config test/webpack.config-v8.js",
"build": "sf lint && sf b -p && npm run build-test && npm run build-docs",
"test": "node ./test/test.js && npm run build-docs",
"dev": "sf d v8",
"patch": "npm run build && sf publish patch -r"
},
"workspaces": [
"packages/*"
"packages/*",
"test"
],
"files": [
"lib"
Expand All @@ -46,22 +47,11 @@
"turbogrid": "~3.0.12"
},
"devDependencies": {
"babel-loader": "^9.1.3",
"babel-plugin-istanbul": "^6.1.1",
"eslint": "^8.56.0",
"eslint-config-plus": "^1.0.6",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-vue": "^9.19.2",
"github-markdown-css": "^5.5.0",
"koa": "^2.14.2",
"koa-static-resolver": "^1.0.4",
"marked": "^11.1.0",
"playwright": "^1.40.1",
"stylelint": "^15.11.0",
"stylelint-config-plus": "^1.0.4",
"ts-loader": "^9.5.1",
"typescript": "^5.3.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
"stylelint-config-plus": "^1.0.4"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "monocart-coverage-test",
"version": "1.0.0",
"description": "",
"main": "",
"scripts": {},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-loader": "^9.1.3",
"babel-plugin-istanbul": "^6.1.1",
"github-markdown-css": "^5.5.0",
"koa": "^2.14.2",
"koa-static-resolver": "^1.0.4",
"marked": "^11.1.0",
"playwright": "^1.40.1",
"ts-loader": "^9.5.1",
"typescript": "^5.3.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/test.js → test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const serverPort = 8130;
const serverUrl = `http://localhost:${serverPort}`;

const serve = () => {
const mockDir = path.resolve(__dirname, '../mock');
const mockDir = path.resolve(__dirname, './mock');

console.log('serve dir', mockDir);

Expand Down Expand Up @@ -94,9 +94,9 @@ const test = async () => {


await Promise.all([
testV8(serverUrl),
testIstanbul(serverUrl),
testV8Minify(serverUrl),
testIstanbul(serverUrl)
testV8(serverUrl)
]);

console.log('close server ...');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Do NOT put in tests folder
const path = require('path');
module.exports = {
mode: 'development',

devtool: 'source-map',

entry: path.resolve('mock/src/index.js'),
entry: path.resolve('test/mock/src/index.js'),

output: {
path: path.resolve('mock/istanbul/dist'),
path: path.resolve('test/mock/istanbul/dist'),
filename: 'coverage-istanbul.js',
umdNamedDefine: true,
library: 'coverage-istanbul',
Expand All @@ -22,7 +21,10 @@ module.exports = {
loader: 'babel-loader',
options: {
plugins: [
['istanbul', {}]
['istanbul', {
// the test or tests folder will be excluded by default
'exclude': []
}]
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions mock/webpack.config-v8.js → test/webpack.config-v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module.exports = {

devtool: 'source-map',

entry: path.resolve('mock/src/index.js'),
entry: path.resolve('test/mock/src/index.js'),

output: {
path: path.resolve('mock/v8/dist'),
path: path.resolve('test/mock/v8/dist'),
filename: 'coverage-v8.js',
umdNamedDefine: true,
library: 'coverage-v8',
Expand Down

0 comments on commit fb39c30

Please sign in to comment.