Skip to content
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

feat: [BREAKING CHANGE] drop espower support #197

Merged
merged 4 commits into from
Dec 18, 2022
Merged
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
26 changes: 0 additions & 26 deletions .autod.conf

This file was deleted.

7 changes: 2 additions & 5 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ name: CI

on:
push:
branches: [ master, main ]
branches: [ master, 5.x ]

pull_request:
branches: [ master, main, next, beta, '*.x' ]

schedule:
- cron: '0 2 * * *'
branches: [ master, 5.x ]

workflow_dispatch: {}

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Release
on:
# 合并后自动发布
push:
branches: [ master ]
branches: [ master, 5.x ]

# 手动发布
workflow_dispatch: {}

jobs:
Expand All @@ -16,4 +14,3 @@ jobs:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
checkTest: false
# dryRun: true
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Start dev cluster on `local` env, it will start a master, an agent and a worker.
egg-bin dev
```

##### options
#### dev options

- `--framework` egg web framework root path.
- `--baseDir` application's root path, default to `process.cwd()`.
Expand All @@ -93,7 +93,7 @@ if running without `VSCode` or `WebStorm`, we will use [inspector-proxy](https:/
egg-bin debug --debug-port=9229 --proxy=9999
```

##### options
#### debug options

- all `egg-bin dev` options is accepted.
- `--proxy=9999` worker debug proxy port.
Expand All @@ -102,8 +102,6 @@ egg-bin debug --debug-port=9229 --proxy=9999

Using [mocha] to run test.

[power-assert] is the default `assert` library, and [intelli-espower-loader] will be auto required.

```bash
egg-bin test [files] [options]
```
Expand All @@ -121,7 +119,7 @@ test
└── foo.test.js
```

#### options
#### test options

You can pass any mocha argv.

Expand All @@ -132,14 +130,13 @@ You can pass any mocha argv.
- `--typescript` / `--ts` enable typescript support, default to `false`.
- `--changed` / `-c` only test changed test files(test files means files that match `${pwd}/test/**/*.test.(js|ts)`)
- `--dry-run` / `-d` whether dry-run the test command, just show the command
- `--espower` / `-e` whether auto require intelli-espower-loader(js) or espower-typescript(ts) for power-assert, default to `false`.
- `--parallel` enable mocha parallel mode, default to `false`.
- `--auto-agent` auto start agent in mocha master agent.
- `--jobs` number of jobs to run in parallel, default to `os.cpus().length - 1`.
- `--mochawesome` enable [mochawesome](https://github.com/adamgruber/mochawesome) reporter, default to `false`.
- see more at <https://mochajs.org/#usage>

#### environment
#### test environment

Environment is also support, will use it if options not provide.

Expand All @@ -165,8 +162,6 @@ TEST_TIMEOUT=2000 egg-bin test

Using [node:test] to run test.

[power-assert] is the default `assert` library, and [intelli-espower-loader] will be auto required.

```bash
egg-bin node-test [files] [options]
```
Expand All @@ -180,7 +175,7 @@ egg-bin node-test [files] [options]

TBD: TypeScript not support yet

#### environment
#### node-test environment

Environment is also support, will use it if options not provide.

Expand Down Expand Up @@ -371,9 +366,6 @@ This project follows the git-contributor [spec](https://github.com/xudafeng/git-
[node:test]: https://nodejs.org/api/test.html
[glob]: https://github.com/isaacs/node-glob
[nsp]: https://npmjs.com/nsp
[iron-node]: https://github.com/s-a/iron-node
[intelli-espower-loader]: https://github.com/power-assert-js/intelli-espower-loader
[power-assert]: https://github.com/power-assert-js/power-assert
[ypkgfiles]: https://github.com/popomore/ypkgfiles
[common-bin]: https://github.com/node-modules/common-bin
[autod]: https://github.com/node-modules/autod
24 changes: 3 additions & 21 deletions lib/cmd/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ class TestCommand extends Command {
description: 'whether show test command, no test will be executed',
alias: 'd',
},
espower: {
type: 'boolean',
description: 'whether require intelli-espower-loader(js) or espower-typescript(ts) for power-assert',
default: false,
alias: 'e',
},
parallel: {
type: 'boolean',
description: 'mocha parallel mode',
Expand Down Expand Up @@ -106,10 +100,11 @@ class TestCommand extends Command {
* @param {Object} context - { cwd, argv, ...}
* @param {Object} context.argv test arguments
* @param {Object} context.debugOptions debug options
* @param {Object} context.execArgvObj exec argv object
* @return {Array} [ '--require=xxx', 'xx.test.js' ]
* @protected
*/
async formatTestArgs({ argv, debugOptions }) {
async formatTestArgs({ argv, debugOptions, execArgvObj }) {
const testArgv = Object.assign({}, argv);

/* istanbul ignore next */
Expand All @@ -127,24 +122,11 @@ class TestCommand extends Command {
}

// collect require
let requireArr = testArgv.require || testArgv.r || [];
/* istanbul ignore next */
if (!Array.isArray(requireArr)) requireArr = [ requireArr ];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const requireArr = execArgvObj.require;

// clean mocha stack, inspired by https://github.com/rstacruz/mocha-clean
// [mocha built-in](https://github.com/mochajs/mocha/blob/master/lib/utils.js#L738) don't work with `[npminstall](https://github.com/cnpm/npminstall)`, so we will override it.
if (!testArgv.fullTrace) requireArr.unshift(require.resolve('../mocha-clean'));

if (requireArr.includes('intelli-espower-loader')) {
console.warn('[egg-bin] don\'t need to manually require `intelli-espower-loader` anymore');
} else if (testArgv.espower) {
if (testArgv.typescript) {
// espower-typescript must append after ts-node
requireArr.push(testArgv.tscompiler, require.resolve('../espower-typescript'));
} else {
requireArr.push(require.resolve('intelli-espower-loader'));
}
}
if (testArgv.parallel && testArgv['auto-agent']) {
try {
requireArr.push(require.resolve('egg-mock/lib/parallel/agent_register'));
Expand Down
41 changes: 0 additions & 41 deletions lib/espower-typescript.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/mocha-clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const internal = [
'at Promise (<anonymous>)',
'at next (native)',
'__mocha_internal__',
/node_modules\/.*empower-core\//,
/node_modules\/.*mocha\//,
/node_modules\/.*co\//,
/node_modules\/.*supertest\//,
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@
"detect-port": "^1.3.0",
"egg-ts-helper": "^1.30.3",
"egg-utils": "^2.4.1",
"espower-source": "^2.3.0",
"espower-typescript": "^10.0.0",
"globby": "^11.1.0",
"inspector-proxy": "^1.2.2",
"intelli-espower-loader": "^1.1.0",
"jest-changed-files": "^28.0.2",
"minimatch": "^5.1.0",
"mocha": "^10.0.0",
"mochawesome": "^7.1.3",
"power-assert": "^1.6.1",
"semver": "^7.3.7",
"source-map-support": "^0.5.21",
"test": "^3.0.0",
Expand All @@ -56,7 +52,7 @@
"coffee": "^5.4.0",
"cpy": "^8.1.2",
"cross-env": "^3.1.3",
"egg": "^2.35.0",
"egg": "^3.9.1",
"egg-mock": "^5.0.2",
"enzyme": "^2.0.0",
"esbuild-register": "^2.5.0",
Expand Down Expand Up @@ -89,8 +85,7 @@
"test-mochawesome": "npm run test-local -- --mochawesome",
"cov": "c8 -r lcov -r text-summary npm run test-local",
"ci-test-only": "npm run test-local -- test/lib/cmd/cov.test.js",
"ci": "npm run lint && npm run pkgfiles -- --check && npm run ci-test-only && npm run test-local",
"autod": "node bin/egg-bin.js autod"
"ci": "npm run lint && npm run pkgfiles -- --check && npm run ci-test-only && npm run test-local"
},
"engines": {
"node": ">= 14.0.0"
Expand Down
24 changes: 7 additions & 17 deletions test/fixtures/example-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
{
"extends": "@eggjs/tsconfig",
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"strict": true,
"noImplicitAny": false,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"pretty": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"inlineSourceMap": true,
"importHelpers": true
},
}
"declaration": false,
"resolveJsonModule": true,
"baseUrl": ".",
"useUnknownInCatchVariables": false
}
}

This file was deleted.

9 changes: 0 additions & 9 deletions test/fixtures/test-files-c8/test/power-assert-fail.js

This file was deleted.

9 changes: 0 additions & 9 deletions test/fixtures/test-files/test/power-assert-fail.js

This file was deleted.

23 changes: 0 additions & 23 deletions test/lib/cmd/cov-c8-report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,6 @@ describe('test/lib/cmd/cov-c8-report.test.js', () => {
.end();
});

it('should fail when test fail with power-assert', () => {
mm(process.env, 'TESTS', 'test/power-assert-fail.js');
return coffee.fork(eggBin, [ 'cov', '--c8-report=true', '--espower=true' ], { cwd })
// .debug()
.expect('stdout', /1\) should fail/)
.expect('stdout', /1 failing/)
.expect('stdout', /assert\(1 === 2\)/)
.expect('code', 1)
.end();
});

it('should warn when require intelli-espower-loader', () => {
mm(process.env, 'TESTS', 'test/power-assert-fail.js');
return coffee.fork(eggBin, [ 'cov', '--c8-report=true', '-r', 'intelli-espower-loader' ], { cwd })
// .debug()
.expect('stderr', /manually require `intelli-espower-loader`/)
.expect('stdout', /1\) should fail/)
.expect('stdout', /1 failing/)
.expect('stdout', /assert\(1 === 2\)/)
.expect('code', 1)
.end();
});

it('should run cov when no test files', () => {
mm(process.env, 'TESTS', 'noexist.js');
const cwd = path.join(__dirname, '../../fixtures/prerequire');
Expand Down
23 changes: 0 additions & 23 deletions test/lib/cmd/cov.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,29 +143,6 @@ describe('test/lib/cmd/cov.test.js', () => {
.end();
});

it('should fail when test fail with power-assert', () => {
mm(process.env, 'TESTS', 'test/power-assert-fail.js');
return coffee.fork(eggBin, [ 'cov', '--espower=true' ], { cwd })
// .debug()
.expect('stdout', /1\) should fail/)
.expect('stdout', /1 failing/)
.expect('stdout', /assert\(1 === 2\)/)
.expect('code', 1)
.end();
});

it('should warn when require intelli-espower-loader', () => {
mm(process.env, 'TESTS', 'test/power-assert-fail.js');
return coffee.fork(eggBin, [ 'cov', '-r', 'intelli-espower-loader' ], { cwd })
// .debug()
.expect('stderr', /manually require `intelli-espower-loader`/)
.expect('stdout', /1\) should fail/)
.expect('stdout', /1 failing/)
.expect('stdout', /assert\(1 === 2\)/)
.expect('code', 1)
.end();
});

it('should run cov when no test files', () => {
mm(process.env, 'TESTS', 'noexist.js');
const cwd = path.join(__dirname, '../../fixtures/prerequire');
Expand Down
Loading