This commit is contained in:
Elizabeth Craig 2023-03-08 21:25:00 -08:00 коммит произвёл GitHub
Родитель e99a82aaf3
Коммит c3711804c4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
18 изменённых файлов: 688 добавлений и 828 удалений

33
.vscode/launch.json поставляемый
Просмотреть файл

@ -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(() => {

23
scripts/debugTests.js Normal file
Просмотреть файл

@ -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

Разница между файлами не показана из-за своего большого размера Загрузить разницу