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: add test verifying PnP works #11513

Merged
merged 8 commits into from
Jun 3, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ jobs:
run: yarn test-types
- name: verify [email protected] compatibility
run: yarn verify-old-ts
- name: verify Yarn PnP compatibility
run: yarn verify-pnp
- name: run eslint
run: yarn lint
- name: run prettier
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"test-leak": "yarn jest -i --detectLeaks jest-mock jest-diff jest-repl pretty-format",
"test": "yarn lint && yarn jest",
"verify-old-ts": "node ./scripts/verifyOldTs.js",
"verify-pnp": "node ./scripts/verifyPnP.js",
"watch": "yarn build:js && node ./scripts/watch.js",
"watch:ts": "yarn build:ts --watch"
},
Expand Down
65 changes: 65 additions & 0 deletions scripts/verifyPnP.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const dedent = require('dedent');
const execa = require('execa');
const rimraf = require('rimraf');
const tempy = require('tempy');

const rootDirectory = path.resolve(__dirname, '..');

const cwd = tempy.directory();

try {
fs.writeFileSync(
path.join(cwd, '.yarnrc.yml'),
dedent`
enableGlobalCache: true

yarnPath: ${require.resolve('../.yarn/releases/yarn-2.4.2.cjs')}
`,
);
fs.writeFileSync(
path.join(cwd, 'package.json'),
JSON.stringify(
{
dependencies: {
jest: `*`,
},
name: 'test-pnp',
},
null,
2,
),
);
fs.writeFileSync(
path.join(cwd, 'test.js'),
dedent`
/*
* @jest-environment jsdom
*/

test('dummy', () => {
expect(window).toBeDefined();
});
`,
);
execa.sync('yarn', ['link', '--private', '--all', rootDirectory], {
cwd,
stdio: 'inherit',
});
execa.sync('yarn', ['jest'], {cwd, stdio: 'inherit'});

console.log(chalk.inverse.green(` Successfully ran Jest with PnP linker `));
} finally {
rimraf.sync(cwd);
}