Skip to content
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
5 changes: 5 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
const {mergeMochaConfigs} = require('./packages/build');
const defaultConfig = require('./packages/build/config/.mocharc.json');

const MONOREPO_CONFIG = {
parallel: true,
};

module.exports = mergeMochaConfigs(
defaultConfig,
MONOREPO_CONFIG,
// Apply Mocha config from packages that require custom Mocha setup
require('./packages/cli/.mocharc.js'),
);
36 changes: 35 additions & 1 deletion docs/site/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ npm test

It does all you need:

- Compile TypeScript
- Compile TypeScript (full rebuild)
- Run all tests
- Check code formatting using [Prettier](https://prettier.io/)
- Lint the code using [ESLint](https://typescript-eslint.io/)
Expand All @@ -161,6 +161,40 @@ Or use a simpler form on Mac and Linux.
CI=1 npm test
```

Running the full test suite after each small change is not very effective. You
can use the following commands to run a subset of checks:

- `npm run build` for a fast incremental build
- `npm run mocha` to (re)run the test suite

We are running tests in parallel, use the Mocha option `-j` (`--jobs`) to
control the number of worker processes or disable parallel execution entirely by
using a single job only:

```
$ npm run mocha -- -j 1
```

When working in a single package, it's possible to limit the compilation to this
package & its dependencies and then run only package tests.

For example, run the following Unix command in `loopback-next` root directory to
build and test changes made in `@loopback/rest` only:

```
$ (cd packages/rest && npm t)
```

On Windows, you have to change the working directory once and then you can
repeatedly run `npm t` inside the package.

```bat
rem Run this only once
cd packages/rest
rem Run this to build & test your changes
npm t
```

## Coding rules

- All features and bug fixes must be covered by one or more automated tests.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"build:site": "./bin/build-docs-site.sh",
"docs:prepare": "./docs/bin/build-preview-site.sh",
"docs:start": "cd docs/_preview && bundle exec jekyll serve --no-w --i",
"mocha": "node packages/build/bin/run-mocha --lang en_US.UTF-8 --timeout 5000 \"packages/*/dist/__tests__/**/*.js\" \"extensions/*/dist/__tests__/**/*.js\" \"examples/*/dist/__tests__/**/*.js\" \"packages/cli/test/**/*.js\" \"packages/build/test/*/*.js\"",
"mocha": "node packages/build/bin/run-mocha --lang en_US.UTF-8 \"packages/*/dist/__tests__/**/*.js\" \"extensions/*/dist/__tests__/**/*.js\" \"examples/*/dist/__tests__/**/*.js\" \"packages/cli/test/**/*.js\" \"packages/build/test/*/*.js\"",
"posttest": "npm run lint"
},
"config": {
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/test/integration/cli/cli.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ describe('cli', () => {
expect(entries).to.not.containEql('Available commands:');
});

it('saves command metadata to .yo-rc.json', () => {
it('saves command metadata to .yo-rc.json', function () {
// This test can be slow under parallel mode
// eslint-disable-next-line @typescript-eslint/no-invalid-this
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not ideal. I opened a PR to avoid eslint-disable-next-line, see #5925

this.timeout(15000);
const entries = [];
main({meta: true}, getLog(entries));
const logs = entries.join('');
Expand Down