Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/origin/override_module_create_re…
Browse files Browse the repository at this point in the history
…quire' into origin/override_module_create_require
  • Loading branch information
doniyor2109 committed Feb 1, 2020
2 parents e0dab93 + 31a7aa6 commit 1bac894
Show file tree
Hide file tree
Showing 33 changed files with 547 additions and 368 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Run npx envinfo --preset jest
Paste the results here:
-->

```bash
```
```
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ Issues without a reproduction link are likely to stall.

Paste the results here:

```bash
```
```
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

### Fixes

- `[jest-snapshot]` Downgrade semver to v6 to support node 8 ([#9451](https://github.com/facebook/jest/pull/9451))
- `[jest-transform]` Correct sourcemap behavior for transformed and instrumented code ([#9460](https://github.com/facebook/jest/pull/9460))
- `[pretty-format]` Export `OldPlugin` type ([#9491](https://github.com/facebook/jest/pull/9491))

### Chore & Maintenance

- `[@jest/reporters]` Remove unused dependencies and type exports ([#9462](https://github.com/facebook/jest/pull/9462))
- `[website]` Update pictures of reports when matchers fail ([#9214](https://github.com/facebook/jest/pull/9214))
- `[docs]` Warn about unexpected behavior / bug of node-notifier when using the `notify` options.

### Performance

Expand Down
8 changes: 8 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ Default: `false`

Activates notifications for test results.

**Beware:** Jest uses [node-notifier](https://github.com/mikaelbr/node-notifier) to display desktop notifications. On Windows, it creates a new start menu entry on the first use and not display the notification. Notifications will be properly displayed on subsequent runs

### `notifyMode` [string]

Default: `failure-change`
Expand Down Expand Up @@ -1083,6 +1085,12 @@ class CustomSequencer extends Sequencer {
module.exports = CustomSequencer;
```

### `testTimeout` [number]

Default: `5000`

Default timeout of a test in milliseconds.

### `testURL` [string]

Default: `http://localhost`
Expand Down
12 changes: 9 additions & 3 deletions docs/TestingAsyncCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,21 @@ There is an alternate form of `test` that fixes this. Instead of putting the tes
```js
test('the data is peanut butter', done => {
function callback(data) {
expect(data).toBe('peanut butter');
done();
try {
expect(data).toBe('peanut butter');
done();
} catch (error) {
done(error);
}
}

fetchData(callback);
});
```

If `done()` is never called, the test will fail, which is what you want to happen.
If `done()` is never called, the test will fail (with timeout error), which is what you want to happen.

In case `expect` statement fails it throws an error and `done()` is not called. If we want to see in the test log why it failed, we have to wrap `expect` in `try` block and pass error in `catch` block to `done`. Otherwise, we end up with opaque timeout error and no knowledge of what value was received by `expect(data)`.

## Promises

Expand Down
3 changes: 2 additions & 1 deletion examples/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
"zone.js": "~0.9.1"
},
"devDependencies": {
"@babel/core": "*",
"@babel/plugin-proposal-class-properties": "*",
"@babel/plugin-proposal-decorators": "*",
"@babel/preset-env": "*",
"@babel/preset-typescript": "*",
"@types/jest": "*",
"babel-jest": "*",
"babel-plugin-transform-typescript-metadata": "*",
"@types/jest": "*",
"jest": "*",
"jest-zone-patch": "*"
}
Expand Down
5 changes: 3 additions & 2 deletions examples/mongodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"license": "MIT",
"private": true,
"dependencies": {
"jest-environment-node": "*",
"mongodb": "^3.1.13",
"mongodb-memory-server": "^6.1.1",
"jest-environment-node": "*"
"mongodb-memory-server": "^6.1.1"
},
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*"
Expand Down
Empty file removed jest-worker
Empty file.
16 changes: 0 additions & 16 deletions jsconfig.json

This file was deleted.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/plugin-proposal-class-properties": "^7.3.4",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
"@babel/plugin-transform-strict-mode": "^7.0.0",
"@babel/preset-env": "^7.1.0",
Expand Down Expand Up @@ -58,8 +59,8 @@
"karma-mocha": "^1.3.0",
"karma-webpack": "^4.0.2",
"lerna": "3.20.2",
"make-dir": "^3.0.0",
"micromatch": "^4.0.2",
"mkdirp": "^0.5.1",
"mocha": "^7.0.0",
"mock-fs": "^4.4.1",
"opencollective": "^1.0.3",
Expand All @@ -68,7 +69,7 @@
"progress": "^2.0.0",
"promise": "^8.0.2",
"realpath-native": "^2.0.0",
"resolve": "^1.4.0",
"resolve": "^1.15.0",
"rimraf": "^3.0.0",
"slash": "^3.0.0",
"string-length": "^3.1.0",
Expand All @@ -92,7 +93,7 @@
"lint:prettier": "yarn --silent lint:prettier:ci --fix",
"lint:prettier:ci": "prettylint '**/*.{md,yml,yaml}' --ignore-path .gitignore",
"postinstall": "opencollective postinstall && yarn build",
"install-no-ts-build": "node scripts/remove-postinstall && yarn --no-progress --frozen-lockfile --ignore-engines && node scripts/build",
"install-no-ts-build": "node scripts/remove-postinstall && yarn --no-progress --frozen-lockfile && node scripts/build",
"publish": "yarn build-clean && yarn build && lerna publish --silent",
"test-ci-es5-build-in-browser": "karma start --single-run",
"test-ci": "yarn jest-coverage --color -i --config jest.config.ci.js && yarn test-leak && node scripts/mapCoverage.js && codecov",
Expand Down
4 changes: 1 addition & 3 deletions packages/jest-repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
"devDependencies": {
"@types/yargs": "^15.0.0"
},
"bin": {
"jest-repl": "./bin/jest-repl.js"
},
"bin": "./bin/jest-repl.js",
"engines": {
"node": ">= 8.3"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/jest-reporters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"dependencies": {
"@bcoe/v8-coverage": "^0.2.3",
"@jest/console": "^25.1.0",
"@jest/environment": "^25.1.0",
"@jest/test-result": "^25.1.0",
"@jest/transform": "^25.1.0",
"@jest/types": "^25.1.0",
Expand All @@ -22,7 +21,6 @@
"istanbul-reports": "^3.0.0",
"jest-haste-map": "^25.1.0",
"jest-resolve": "^25.1.0",
"jest-runtime": "^25.1.0",
"jest-util": "^25.1.0",
"jest-worker": "^25.1.0",
"slash": "^3.0.0",
Expand All @@ -36,7 +34,7 @@
"@types/glob": "^7.1.1",
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-lib-instrument": "^1.7.2",
"@types/istanbul-lib-report": "^1.1.0",
"@types/istanbul-lib-report": "^3.0.0",
"@types/istanbul-lib-source-maps": "^1.2.1",
"@types/istanbul-reports": "^1.1.0",
"@types/node-notifier": "^5.4.0",
Expand Down
17 changes: 9 additions & 8 deletions packages/jest-reporters/src/coverage_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ export default class CoverageReporter extends BaseReporter {
transformedCoverage.forEach(res => map.merge(res));

const reportContext = istanbulReport.createContext({
// @ts-ignore
coverageMap: map,
dir: this._globalConfig.coverageDirectory,
watermarks: getWatermarks(this._globalConfig),
Expand All @@ -502,14 +501,16 @@ export default class CoverageReporter extends BaseReporter {
}

const map = await this._sourceMapStore.transformCoverage(this._coverageMap);
const reportContext = istanbulReport.createContext({
// @ts-ignore
coverageMap: map,
dir: this._globalConfig.coverageDirectory,
const reportContext = istanbulReport.createContext(
// @ts-ignore
sourceFinder: this._sourceMapStore.sourceFinder,
watermarks: getWatermarks(this._globalConfig),
});
{
coverageMap: map,
dir: this._globalConfig.coverageDirectory,
// @ts-ignore
sourceFinder: this._sourceMapStore.sourceFinder,
watermarks: getWatermarks(this._globalConfig),
},
);

// @ts-ignore
return {map, reportContext};
Expand Down
14 changes: 0 additions & 14 deletions packages/jest-reporters/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import {
SerializableError,
TestResult,
} from '@jest/test-result';
import {JestEnvironment as Environment} from '@jest/environment';
import {FS as HasteFS, ModuleMap} from 'jest-haste-map';
import HasteResolver = require('jest-resolve');
import Runtime = require('jest-runtime');
import {worker} from './coverage_worker';

export type ReporterOnStartOptions = {
Expand Down Expand Up @@ -76,22 +74,10 @@ export type SummaryOptions = {
width?: number;
};

export type TestFramework = (
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
environment: Environment,
runtime: Runtime,
testPath: string,
) => Promise<TestResult>;

export type TestRunnerOptions = {
serial: boolean;
};

export type TestRunnerContext = {
changedFiles?: Set<Config.Path>;
};

export type TestRunData = Array<{
context: Context;
matches: {allTests: number; tests: Array<Test>; total: number};
Expand Down
2 changes: 0 additions & 2 deletions packages/jest-reporters/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
},
"references": [
{"path": "../jest-console"},
{"path": "../jest-environment"},
{"path": "../jest-haste-map"},
{"path": "../jest-resolve"},
{"path": "../jest-runtime"},
{"path": "../jest-test-result"},
{"path": "../jest-types"},
{"path": "../jest-util"},
Expand Down
4 changes: 1 addition & 3 deletions packages/jest-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
"@types/graceful-fs": "^4.1.2",
"jest-environment-node": "^25.1.0"
},
"bin": {
"jest-runtime": "./bin/jest-runtime.js"
},
"bin": "./bin/jest-runtime.js",
"engines": {
"node": ">= 8.3"
},
Expand Down
5 changes: 2 additions & 3 deletions packages/jest-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
"jest-matcher-utils": "^25.1.0",
"jest-message-util": "^25.1.0",
"jest-resolve": "^25.1.0",
"mkdirp": "^0.5.1",
"make-dir": "^3.0.0",
"natural-compare": "^1.4.0",
"pretty-format": "^25.1.0",
"semver": "^7.1.1"
"semver": "^6.3.0"
},
"devDependencies": {
"@babel/traverse": "^7.3.4",
"@types/mkdirp": "^0.5.2",
"@types/natural-compare": "^1.4.0",
"@types/prettier": "^1.16.1",
"@types/semver": "^6.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-snapshot/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import * as fs from 'fs';
import * as path from 'path';
import {sync as mkdirp} from 'mkdirp';
import makeDir = require('make-dir');
import naturalCompare = require('natural-compare');
import chalk = require('chalk');
import {Config} from '@jest/types';
Expand Down Expand Up @@ -183,7 +183,7 @@ const printBacktickString = (str: string): string =>

export const ensureDirectoryExists = (filePath: Config.Path) => {
try {
mkdirp(path.join(path.dirname(filePath)), '777');
makeDir.sync(path.join(path.dirname(filePath)));
} catch (e) {}
};

Expand Down
Loading

0 comments on commit 1bac894

Please sign in to comment.