Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run yarn with immutable flag #10767

Merged
merged 3 commits into from Nov 2, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .azure-pipelines-steps.yml
Expand Up @@ -6,11 +6,11 @@ steps:
- checkout: self
path: jest

# Ensure Node.js 12 is active
# Ensure Node.js 14 is active
- task: NodeTool@0
inputs:
versionSpec: '12.x'
displayName: 'Use Node.js 12'
versionSpec: '14.x'
displayName: 'Use Node.js 14'

# Ensure Python 2.7 is active
- task: UsePythonVersion@0
Expand All @@ -27,7 +27,7 @@ steps:
path: $(yarnCache.folder)
displayName: Cache Yarn packages

- script: yarn install
- script: yarn install --immutable
displayName: 'Install dependencies'

- script: yarn build:js
Expand Down
6 changes: 3 additions & 3 deletions .circleci/config.yml
Expand Up @@ -4,7 +4,7 @@ aliases:
ignore: gh-pages
- &install
pkg-manager: yarn
override-ci-command: yarn install && yarn build:js
override-ci-command: yarn install --immutable && yarn build:js
cache-path: ~/.yarn/berry/cache
include-branch-in-cache-key: false
app-dir: ~/jest
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
install-npm: false
- node/install-packages: *install
- run:
command: yarn test-ci
command: yarn test-ci-partial
- store_test_results:
path: reports/junit

Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
install-npm: false
- node/install-packages: *install
- run:
command: yarn test-ci-partial
command: yarn test-ci
- store_test_results:
path: reports/junit

Expand Down
4 changes: 2 additions & 2 deletions .circleci/website.sh
Expand Up @@ -13,7 +13,7 @@ else
git config --global user.name "Website Deployment Script"
echo "machine github.com login docusaurus-bot password $DOCUSAURUS_PUBLISH_TOKEN" > ~/.netrc
# install Docusaurus and generate file of English strings
yarn && cd website && node fetchSupporters.js && yarn write-translations
yarn --immutable && cd website && node fetchSupporters.js && yarn write-translations
# crowdin install
sudo apt-get update
sudo apt-get install default-jre rsync
Expand All @@ -30,6 +30,6 @@ else
GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages
else
echo "Skipping deploy. Test website build"
cd website && yarn && node fetchSupporters.js && yarn build
yarn --immutable && cd website && node fetchSupporters.js && yarn build
fi
fi
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
node-version: 12.x
- name: install
run: yarn
run: yarn --immutable
- name: build
run: yarn build
- name: test typings
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: install
run: yarn
run: yarn --immutable
- name: build
run: yarn build:js
- name: Get number of CPU cores
Expand Down
9 changes: 7 additions & 2 deletions e2e/Utils.ts
Expand Up @@ -44,15 +44,20 @@ export const run = (
return result;
};

export const runYarn = (cwd: Config.Path, env?: Record<string, string>) => {
export const runYarnInstall = (
cwd: Config.Path,
env?: Record<string, string>,
) => {
const lockfilePath = path.resolve(cwd, 'yarn.lock');
let exists = true;

// If the lockfile doesn't exist, yarn's project detection is confused. Just creating an empty file works
if (!fs.existsSync(lockfilePath)) {
exists = false;
fs.writeFileSync(lockfilePath, '');
}

return run('yarn', cwd, env);
return run(exists ? 'yarn install --immutable' : 'yarn install', cwd, env);
};

export const linkJestPackage = (packageName: string, cwd: Config.Path) => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/asyncRegenerator.test.ts
Expand Up @@ -6,13 +6,13 @@
*/

import * as path from 'path';
import {runYarn} from '../Utils';
import {runYarnInstall} from '../Utils';
import {json as runWithJson} from '../runJest';

const dir = path.resolve(__dirname, '../async-regenerator');

beforeEach(() => {
runYarn(dir);
runYarnInstall(dir);
});

test('successfully transpiles async', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/babelPluginJestHoist.test.ts
Expand Up @@ -6,13 +6,13 @@
*/

import * as path from 'path';
import {runYarn} from '../Utils';
import {runYarnInstall} from '../Utils';
import {json as runWithJson} from '../runJest';

const DIR = path.resolve(__dirname, '..', 'babel-plugin-jest-hoist');

beforeEach(() => {
runYarn(DIR);
runYarnInstall(DIR);
});

it('successfully runs the tests inside `babel-plugin-jest-hoist/`', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/chaiAssertionLibrary.ts
Expand Up @@ -7,12 +7,12 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {extractSummary, runYarn} from '../Utils';
import {extractSummary, runYarnInstall} from '../Utils';
import runJest from '../runJest';

test('chai assertion errors should display properly', () => {
const dir = path.resolve(__dirname, '../chai-assertion-library-errors');
runYarn(dir);
runYarnInstall(dir);

const {stderr} = runJest('chai-assertion-library-errors');
const {rest} = extractSummary(stderr);
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/console.test.ts
Expand Up @@ -7,7 +7,7 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {extractSummary, runYarn} from '../Utils';
import {extractSummary, runYarnInstall} from '../Utils';
import runJest from '../runJest';

test('console printing', () => {
Expand Down Expand Up @@ -99,7 +99,7 @@ test('the jsdom console is the same as the test console', () => {

test('does not error out when using winston', () => {
const dir = path.resolve(__dirname, '../console-winston');
runYarn(dir);
runYarnInstall(dir);
const {stderr, stdout, exitCode} = runJest(dir);
const {summary, rest} = extractSummary(stderr);

Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/coverageHandlebars.test.ts
Expand Up @@ -8,7 +8,7 @@
import * as path from 'path';
import {readFileSync} from 'graceful-fs';
import wrap from 'jest-snapshot-serializer-raw';
import {cleanup, runYarn} from '../Utils';
import {cleanup, runYarnInstall} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '../coverage-handlebars');
Expand All @@ -19,7 +19,7 @@ beforeAll(() => {
});

it('code coverage for Handlebars', () => {
runYarn(dir);
runYarnInstall(dir);
const result = runJest(dir, ['--coverage', '--no-cache']);

expect(result.exitCode).toBe(0);
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/coverageRemapping.test.ts
Expand Up @@ -7,7 +7,7 @@

import * as path from 'path';
import {readFileSync} from 'graceful-fs';
import {cleanup, runYarn} from '../Utils';
import {cleanup, runYarnInstall} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '../coverage-remapping');
Expand All @@ -18,7 +18,7 @@ beforeAll(() => {
});

it('maps code coverage against original source', () => {
runYarn(dir);
runYarnInstall(dir);
const result = runJest(dir, ['--coverage', '--no-cache']);

expect(result.exitCode).toBe(0);
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/coverageReport.test.ts
Expand Up @@ -8,13 +8,13 @@
import * as path from 'path';
import * as fs from 'graceful-fs';
import {wrap} from 'jest-snapshot-serializer-raw';
import {extractSummary, runYarn} from '../Utils';
import {extractSummary, runYarnInstall} from '../Utils';
import runJest from '../runJest';

const DIR = path.resolve(__dirname, '../coverage-report');

beforeAll(() => {
runYarn(DIR);
runYarnInstall(DIR);
});

test('outputs coverage report', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/coverageTransformInstrumented.test.ts
Expand Up @@ -7,7 +7,7 @@

import * as path from 'path';
import {readFileSync} from 'graceful-fs';
import {cleanup, runYarn} from '../Utils';
import {cleanup, runYarnInstall} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '../coverage-transform-instrumented');
Expand All @@ -18,7 +18,7 @@ beforeAll(() => {
});

it('code coverage for transform instrumented code', () => {
runYarn(dir);
runYarnInstall(dir);
const result = runJest(dir, ['--coverage', '--no-cache']);

expect(result.exitCode).toBe(0);
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/expectAsyncMatcher.test.ts
Expand Up @@ -7,13 +7,13 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {extractSummary, runYarn} from '../Utils';
import {extractSummary, runYarnInstall} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '../expect-async-matcher');

beforeAll(() => {
runYarn(dir);
runYarnInstall(dir);
});

test('works with passing tests', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/failures.test.ts
Expand Up @@ -7,7 +7,7 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {extractSummary, runYarn} from '../Utils';
import {extractSummary, runYarnInstall} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '../failures');
Expand All @@ -24,7 +24,7 @@ function cleanStderr(stderr: string) {
const nodeMajorVersion = Number(process.versions.node.split('.')[0]);

beforeAll(() => {
runYarn(dir);
runYarnInstall(dir);
});

test('not throwing Error objects', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/globalSetup.test.ts
Expand Up @@ -8,7 +8,7 @@
import {tmpdir} from 'os';
import * as path from 'path';
import * as fs from 'graceful-fs';
import {cleanup, runYarn} from '../Utils';
import {cleanup, runYarnInstall} from '../Utils';
import runJest, {json as runWithJson} from '../runJest';

const DIR = path.join(tmpdir(), 'jest-global-setup');
Expand All @@ -22,7 +22,7 @@ const nodeModulesDIR = path.join(tmpdir(), 'jest-global-setup-node-modules');
const e2eDir = path.resolve(__dirname, '../global-setup');

beforeAll(() => {
runYarn(e2eDir);
runYarnInstall(e2eDir);
});

beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/globalTeardown.test.ts
Expand Up @@ -9,7 +9,7 @@ import {tmpdir} from 'os';
import * as path from 'path';
import * as fs from 'graceful-fs';
import {createDirectory} from 'jest-util';
import {cleanup, runYarn} from '../Utils';
import {cleanup, runYarnInstall} from '../Utils';
import runJest, {json as runWithJson} from '../runJest';

const DIR = path.join(tmpdir(), 'jest-global-teardown');
Expand All @@ -18,7 +18,7 @@ const project2DIR = path.join(tmpdir(), 'jest-global-teardown-project-2');
const e2eDir = path.resolve(__dirname, '../global-teardown');

beforeAll(() => {
runYarn(e2eDir);
runYarnInstall(e2eDir);
});

beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/nativeAsyncMock.test.ts
Expand Up @@ -6,7 +6,7 @@
*/

import * as path from 'path';
import {extractSummary, runYarn} from '../Utils';
import {extractSummary, runYarnInstall} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '..', 'native-async-mock');
Expand All @@ -16,7 +16,7 @@ test('mocks async functions', () => {
return;
}

runYarn(dir);
runYarnInstall(dir);

// --no-cache because babel can cache stuff and result in false green
const {stderr} = runJest(dir, ['--no-cache']);
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/pnp.test.ts
Expand Up @@ -6,13 +6,13 @@
*/

import * as path from 'path';
import {runYarn} from '../Utils';
import {runYarnInstall} from '../Utils';
import {json as runWithJson} from '../runJest';

const DIR = path.resolve(__dirname, '..', 'pnp');

beforeEach(() => {
runYarn(DIR, {YARN_NODE_LINKER: 'pnp'});
runYarnInstall(DIR, {YARN_NODE_LINKER: 'pnp'});
});

it('successfully runs the tests inside `pnp/`', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/stackTraceSourceMaps.test.ts
Expand Up @@ -6,12 +6,12 @@
*/

import * as path from 'path';
import {runYarn} from '../Utils';
import {runYarnInstall} from '../Utils';
import runJest from '../runJest';

it('processes stack traces and code frames with source maps', () => {
const dir = path.resolve(__dirname, '../stack-trace-source-maps');
runYarn(dir);
runYarnInstall(dir);
const {stderr} = runJest(dir, ['--no-cache']);
expect(stderr).toMatch('> 15 | (() => expect(false).toBe(true))();');
expect(stderr).toMatch(`at __tests__/fails.ts:15:24
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/stackTraceSourceMapsWithCoverage.test.ts
Expand Up @@ -6,15 +6,15 @@
*/
import * as path from 'path';
import wrap from 'jest-snapshot-serializer-raw';
import {extractSummary, runYarn} from '../Utils';
import {extractSummary, runYarnInstall} from '../Utils';
import runJest from '../runJest';

it('processes stack traces and code frames with source maps with coverage', () => {
const dir = path.resolve(
__dirname,
'../stack-trace-source-maps-with-coverage',
);
runYarn(dir);
runYarnInstall(dir);
const {stderr} = runJest(dir, ['--no-cache', '--coverage']);

// Should report an error at source line 13 in lib.ts at line 10 of the test
Expand Down