Skip to content

Commit

Permalink
chore(dev-deps): jest 27
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Sep 19, 2021
1 parent c70911d commit c73e076
Show file tree
Hide file tree
Showing 8 changed files with 901 additions and 1,647 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -36,6 +36,7 @@ jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [12.11, 14, 16.8]
steps:
Expand All @@ -61,6 +62,7 @@ jobs:
integration-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [12.11, 14, 16.8]
steps:
Expand All @@ -86,6 +88,7 @@ jobs:
smoke-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [12.11, 14, 16.8]
steps:
Expand All @@ -111,6 +114,7 @@ jobs:
repositories-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [12.11, 14, 16.8]
steps:
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -50,7 +50,7 @@
"@tsconfig/node12": "^1.0.8",
"@types/babel__code-frame": "^7.0.2",
"@types/eslint": "^7.2.2",
"@types/jest": "^26.0.15",
"@types/jest": "^27.0.1",
"@types/node": "^15.0.0",
"@types/object-hash": "^2.1.0",
"@types/react": "^16.9.53",
Expand All @@ -67,13 +67,13 @@
"eslint-remote-tester-repositories": "^0.0.2",
"husky": "^7.0.1",
"ink-testing-library": "^2.1.0",
"jest": "^26.6.1",
"jest": "^27.2.0",
"lint-staged": "^11.0.0",
"node-pty": "^0.10.0",
"prettier": "^2.3.1",
"rimraf": "^3.0.2",
"strip-ansi": "^6.0.0",
"ts-jest": "^26.4.4",
"ts-jest": "^27.0.5",
"tsc-alias": "^1.3.3",
"typescript": "^4.2.4"
},
Expand Down
3 changes: 1 addition & 2 deletions test/integration/jest.setup.integration.ts
@@ -1,7 +1,6 @@
import { addFailureLogger, clearRepositoryCache } from '../utils';
import { clearRepositoryCache } from '../utils';

jest.setTimeout(15000);
addFailureLogger();

beforeEach(async () => {
clearRepositoryCache();
Expand Down
3 changes: 1 addition & 2 deletions test/smoke/jest.setup.smoke.ts
@@ -1,7 +1,6 @@
import { addFailureLogger, clearRepositoryCache } from '../utils';
import { clearRepositoryCache } from '../utils';

jest.setTimeout(300000);
addFailureLogger();

beforeEach(async () => {
clearRepositoryCache();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/file-client.test.ts
Expand Up @@ -101,7 +101,7 @@ function createComparisonResults(): void {
function getCacheLocation() {
let location = '';

jest.resetModuleRegistry();
jest.resetModules();
jest.isolateModules(() => {
location =
require('../../lib/file-client/file-constants').CACHE_LOCATION;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/repository-client.test.ts
Expand Up @@ -21,7 +21,7 @@ describe('repository-client', () => {
}

// Initialize client
jest.resetModuleRegistry();
jest.resetModules();
jest.isolateModules(() => {
require('../../lib/file-client/repository-client');
});
Expand Down
38 changes: 0 additions & 38 deletions test/utils.ts
@@ -1,8 +1,6 @@
import fs from 'fs';
import { spawn } from 'node-pty';
import stripAnsi from 'strip-ansi';
import { Jasmine } from 'jest-jasmine2/build/index.d';
import { Reporter } from 'jest-jasmine2/build/types.d';

import {
CACHE_LOCATION,
Expand All @@ -14,7 +12,6 @@ import { removeDirectorySync } from '@file-client/file-utils';
import { Config, ConfigToValidate } from '@config/types';

declare const console: { log: jest.Mock; error: (...args: any) => void };
declare const jasmine: Jasmine;

export const INTEGRATION_REPO_OWNER = 'AriPerkkio';
export const INTEGRATION_REPO_NAME =
Expand All @@ -27,7 +24,6 @@ const ON_COMPLETE_PATTERN = /("onComplete": )"([\s|\S]*)"/;
const RULES_UNDER_TESTING_PATTERN = /("rulesUnderTesting": )"([\s|\S]*)",/;
const ESLINTRC_PATTERN = /("eslintrc": )"([\s|\S]*)",/;
const ESCAPED_NEWLINE_PATTERN = /\\n/g;
const DEBUG_LOG = '/tmp/test.debug.log';

let idCounter = 0;

Expand Down Expand Up @@ -77,12 +73,6 @@ export async function runProductionBuild(
const { name, cleanup } = createConfiguration(options, baseConfigPath);

return new Promise((resolve, reject) => {
if (fs.existsSync(DEBUG_LOG)) fs.unlinkSync(DEBUG_LOG);

const debugStream = fs.createWriteStream(DEBUG_LOG, {
encoding: 'utf8',
});

const ptyProcess = spawn('node', ['dist', '--config', name], {
cwd: process.cwd(),
encoding: 'utf8',
Expand All @@ -100,12 +90,10 @@ export async function runProductionBuild(
});
const output: string[] = [];
ptyProcess.onData(data => {
debugStream.write(stripAnsi(data));
output.push(data);
});

ptyProcess.onExit(({ exitCode }) => {
debugStream.end();
cleanup();

const parsedOutput = parsePtyOutput(output);
Expand Down Expand Up @@ -210,32 +198,6 @@ export function getComparisonResults(
);
}

/**
* Logs output of node-pty when a test fails.
* Used to debug flaky integration/smoke tests.
*/
export function addFailureLogger(): void {
const specDone: Reporter['specDone'] = async result => {
if (result.status === 'failed') {
if (!fs.existsSync(DEBUG_LOG)) {
return console.error('Debug log missing');
}

const logContent = fs.readFileSync(DEBUG_LOG, 'utf8');
console.log(
[
`Debug log content of "${result.description}"`,
'*********',
logContent,
'*********',
].join('\n')
);
}
};

jasmine.getEnv().addReporter({ specDone });
}

/**
* Get last call arguments of given mocked callback
* - Returns array incase of multiple call arguments
Expand Down

0 comments on commit c73e076

Please sign in to comment.