зеркало из https://github.com/microsoft/just.git
Update to Jest 27 (#695)
This commit is contained in:
Родитель
e99a82aaf3
Коммит
c3711804c4
|
@ -5,19 +5,38 @@
|
|||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug test",
|
||||
"name": "Debug current package tests",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
|
||||
"cwd": "${workspaceFolder}/packages/just-scripts",
|
||||
"args": ["-i", "--runInBand"],
|
||||
"runtimeArgs": ["--nolazy"],
|
||||
"program": "${workspaceRoot}/scripts/debugTests.js",
|
||||
"cwd": "${fileDirname}",
|
||||
"stopOnEntry": false,
|
||||
"args": ["--watchAll"],
|
||||
"runtimeExecutable": null,
|
||||
"runtimeArgs": ["--nolazy", "--inspect"],
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"console": "integratedTerminal",
|
||||
"sourceMaps": true,
|
||||
"outFiles": []
|
||||
"outputCapture": "std",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "Debug current open test",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/scripts/debugTests.js",
|
||||
"cwd": "${fileDirname}",
|
||||
"stopOnEntry": false,
|
||||
"args": ["${fileBasenameNoExtension}"],
|
||||
"runtimeExecutable": null,
|
||||
"runtimeArgs": ["--nolazy", "--inspect"],
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"sourceMaps": true,
|
||||
"outputCapture": "std",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"type": "none",
|
||||
"comment": "Update mock-fs usage in tests",
|
||||
"packageName": "just-scripts-utils",
|
||||
"email": "elcraig@microsoft.com",
|
||||
"dependentChangeType": "none"
|
||||
},
|
||||
{
|
||||
"type": "none",
|
||||
"comment": "Update mock-fs usage in tests",
|
||||
"packageName": "just-task",
|
||||
"email": "elcraig@microsoft.com",
|
||||
"dependentChangeType": "none"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -6,5 +6,5 @@ module.exports = {
|
|||
|
||||
// These are relative to the git root, and affects the hash of the cache
|
||||
// Any of these file changes will invalidate cache
|
||||
environmentGlob: ['*.js', '*.json', '*.yml'],
|
||||
environmentGlob: ['*.js', '*.json', '*.yml', 'scripts'],
|
||||
};
|
||||
|
|
|
@ -31,19 +31,20 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/jest": "26.0.24",
|
||||
"@types/jest": "27.5.2",
|
||||
"@types/mock-fs": "4.13.1",
|
||||
"@types/node": "14.18.36",
|
||||
"@typescript-eslint/eslint-plugin": "5.52.0",
|
||||
"@typescript-eslint/parser": "5.52.0",
|
||||
"beachball": "2.31.11",
|
||||
"eslint": "8.34.0",
|
||||
"gh-pages": "4.0.0",
|
||||
"jest": "26.6.3",
|
||||
"jest": "27.5.1",
|
||||
"lage": "1.9.6",
|
||||
"mock-fs": "4.14.0",
|
||||
"mock-fs": "5.2.0",
|
||||
"prettier": "2.8.4",
|
||||
"syncpack": "8.5.14",
|
||||
"ts-jest": "26.5.6",
|
||||
"ts-jest": "27.1.5",
|
||||
"typescript": "4.1.3",
|
||||
"vuepress": "1.9.8",
|
||||
"vuepress-plugin-mermaidjs": "1.9.1"
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
"@types/jju": "1.4.2",
|
||||
"@types/marked": "4.0.8",
|
||||
"@types/marked-terminal": "3.1.3",
|
||||
"@types/mock-fs": "4.13.1",
|
||||
"@types/semver": "7.3.13",
|
||||
"@types/tar": "6.1.4",
|
||||
"@types/tar-fs": "2.0.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { encodeArgs, exec, ExecError } from '../exec';
|
||||
import { Readable } from 'stream';
|
||||
import cp = require('child_process');
|
||||
import * as cp from 'child_process';
|
||||
|
||||
describe('encodeArgs', () => {
|
||||
it('encodes things with spaces with double quotes', () => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import mockfs = require('mock-fs');
|
||||
import * as mockfs from 'mock-fs';
|
||||
import { paths } from '../paths';
|
||||
import { findMonoRepoRootPath } from '../findMonoRepoRootPath';
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { readPackageJson } from '../readPackageJson';
|
||||
import mockfs = require('mock-fs');
|
||||
import * as mockfs from 'mock-fs';
|
||||
|
||||
describe('readPackageJson', () => {
|
||||
const testDir = 'testDir';
|
||||
const badDir = 'badDir';
|
||||
const testName = 'my-fake-package';
|
||||
|
||||
beforeAll(() => {
|
||||
beforeEach(() => {
|
||||
mockfs({
|
||||
[testDir]: {
|
||||
'package.json': JSON.stringify({ name: testName }),
|
||||
|
@ -17,7 +17,9 @@ describe('readPackageJson', () => {
|
|||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
afterEach(() => {
|
||||
// As of jest 27, it seems that sometimes if fs isn't restored after each test, there's an
|
||||
// error in the result reporting code that tries to load jest-worker.
|
||||
mockfs.restore();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import fs = require('fs');
|
||||
import * as mockfs from 'mock-fs';
|
||||
import * as fs from 'fs';
|
||||
import { _justReadRushJson, _parseRushJson, rushAddPackage } from '../rush';
|
||||
import mockfs = require('mock-fs');
|
||||
import jju = require('jju');
|
||||
import * as jju from 'jju';
|
||||
|
||||
const rushJsonStrNoProjects = `{
|
||||
// this is a comment
|
||||
|
@ -32,19 +32,17 @@ const rushJsonUpdatedStr = `{
|
|||
]
|
||||
}`;
|
||||
|
||||
describe('rushUpdate', () => {
|
||||
// TOOD: not sure what to test here
|
||||
});
|
||||
|
||||
describe('_justReadRushJson', () => {
|
||||
beforeAll(() => {
|
||||
beforeEach(() => {
|
||||
mockfs({
|
||||
root: { 'rush.json': rushJsonStr },
|
||||
badRoot: {},
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
afterEach(() => {
|
||||
// As of jest 27, it seems that sometimes if fs isn't restored after each test, there's an
|
||||
// error in the result reporting code that tries to load jest-worker.
|
||||
mockfs.restore();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import mockfs = require('mock-fs');
|
||||
import * as mockfs from 'mock-fs';
|
||||
import { encodeArgs, exec, spawn } from 'just-scripts-utils';
|
||||
import { TaskFunction } from 'just-task';
|
||||
import { tscTask, tscWatchTask, TscTaskOptions } from '../tscTask';
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/chokidar": "2.1.3",
|
||||
"@types/mock-fs": "4.13.1",
|
||||
"@types/resolve": "1.20.2",
|
||||
"@types/undertaker": "1.2.8",
|
||||
"@types/undertaker-registry": "1.0.1",
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
} from '../resolve';
|
||||
import * as option from '../option';
|
||||
import * as config from '../config';
|
||||
import mockfs = require('mock-fs');
|
||||
import * as mockfs from 'mock-fs';
|
||||
|
||||
describe('_isFileNameLike', () => {
|
||||
it('returns false for empty input', () => {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { parallel, undertaker } from '../undertaker';
|
|||
import { logger } from '../logger';
|
||||
import * as path from 'path';
|
||||
import * as option from '../option';
|
||||
import UndertakerRegistry = require('undertaker-registry');
|
||||
import * as UndertakerRegistry from 'undertaker-registry';
|
||||
|
||||
describe('task', () => {
|
||||
beforeAll(() => {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
// @ts-check
|
||||
const jest = require('jest');
|
||||
const { findPackageRoot } = require('workspace-tools');
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
function start() {
|
||||
const packagePath = findPackageRoot(process.cwd());
|
||||
if (!packagePath) {
|
||||
throw new Error('Could not find package.json relative to ' + process.cwd());
|
||||
}
|
||||
|
||||
process.chdir(packagePath);
|
||||
|
||||
console.log(`Starting Jest debugging at: ${packagePath}`);
|
||||
|
||||
return jest.run(['--runInBand', '--watch', '--testTimeout=999999999', ...args]);
|
||||
}
|
||||
|
||||
start().catch(err => {
|
||||
console.error(err?.stack || err);
|
||||
process.exit(1);
|
||||
});
|
|
@ -1,28 +0,0 @@
|
|||
const DefaultReporter = require('@jest/reporters').DefaultReporter;
|
||||
|
||||
/**
|
||||
* The purpose of this custom reporter is to prevent Jest from logging to stderr
|
||||
* when there are no errors.
|
||||
*/
|
||||
class JestReporter extends DefaultReporter {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this._isLoggingError = false;
|
||||
}
|
||||
|
||||
log(message) {
|
||||
if (this._isLoggingError) {
|
||||
process.stderr.write(message + '\n');
|
||||
} else {
|
||||
process.stdout.write(message + '\n');
|
||||
}
|
||||
}
|
||||
|
||||
printTestFileFailureMessage(...args) {
|
||||
this._isLoggingError = true;
|
||||
super.printTestFileFailureMessage(...args);
|
||||
this._isLoggingError = false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = JestReporter;
|
|
@ -6,11 +6,10 @@ module.exports = {
|
|||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/?(*.)+(spec|test).[jt]s'],
|
||||
reporters: [path.resolve(__dirname, './jest-reporter.js')],
|
||||
verbose: true,
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
tsConfig: path.resolve(process.cwd(), 'tsconfig.json'),
|
||||
tsconfig: path.resolve(process.cwd(), 'tsconfig.json'),
|
||||
packageJson: path.resolve(process.cwd(), 'package.json'),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -5,8 +5,5 @@
|
|||
"description": "",
|
||||
"main": "watch.js",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"@jest/reporters": "^26.6.2"
|
||||
}
|
||||
"author": ""
|
||||
}
|
||||
|
|
1359
yarn.lock
1359
yarn.lock
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче