Skip to content

Commit

Permalink
skip certain tests when installing yarn ignoring the lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Oct 10, 2024
1 parent a36e992 commit 51aeb5a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ jobs:
no-lockfile: ${{ inputs.no-lockfile }}
- name: Run Jest Tests
run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit --rootdir='./'
env:
YARN_INSTALL_NO_LOCKFILE: ${{ inputs.no-lockfile }}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
"setupFiles": [
"<rootDir>/scripts/setupJest.js"
],
"setupFilesAfterEnv": [
"<rootDir>/scripts/setupJestAfterEnv.js"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
Expand Down
21 changes: 12 additions & 9 deletions scripts/__tests__/babel-lib-defs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
import generateBabelFlowLibraryDefinitions from '../support/generateBabelFlowLibraryDefinitions';
import {promises as fsPromises} from 'fs';

test('Babel Flow library definitions should be up to date', async () => {
// Run `yarn update-babel-flow-lib-defs` in the Metro monorepo if this test fails.
const contentByFilePath = await generateBabelFlowLibraryDefinitions();
expect(contentByFilePath).toBeInstanceOf(Map);
expect(contentByFilePath.size).toBe(2);
for (const [filePath, content] of contentByFilePath) {
expect(await fsPromises.readFile(filePath, 'utf8')).toEqual(content);
}
});
test.skipOnYarnInstallNoLockfile(
'Babel Flow library definitions should be up to date',
async () => {
// Run `yarn update-babel-flow-lib-defs` in the Metro monorepo if this test fails.
const contentByFilePath = await generateBabelFlowLibraryDefinitions();
expect(contentByFilePath).toBeInstanceOf(Map);
expect(contentByFilePath.size).toBe(2);
for (const [filePath, content] of contentByFilePath) {
expect(await fsPromises.readFile(filePath, 'utf8')).toEqual(content);
}
},
);
15 changes: 15 additions & 0 deletions scripts/setupJestAfterEnv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @oncall react_native
*/

'use strict';

test.skipOnYarnInstallNoLockfile = process.env.YARN_INSTALL_NO_LOCKFILE
? test.skip
: test;

0 comments on commit 51aeb5a

Please sign in to comment.