Add option to jest to run tests only locally, or on linux (#2609)
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/2609 Make it possible to mark some tests to run on non-CI, or unix only Reviewed By: nikoant Differential Revision: D29813506 fbshipit-source-id: 140f8a4eaed5af3282ab9d139b46a52818be0934
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3f7e3c0441
commit
a78b6124d7
@@ -59,8 +59,7 @@ describe('sideeffect', () => {
|
|||||||
console.error = origError;
|
console.error = origError;
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO(T93353978): Re-enable.
|
test.local('can run a basic effect', async () => {
|
||||||
test.skip('can run a basic effect', async () => {
|
|
||||||
unsubscribe = sideEffect(
|
unsubscribe = sideEffect(
|
||||||
store,
|
store,
|
||||||
{name: 'test', throttleMs: 1},
|
{name: 'test', throttleMs: 1},
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ test('can manually collapse properties', async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO(T95985157): Flaky in open source.
|
test.local('can filter for data', async () => {
|
||||||
test.skip('can filter for data', async () => {
|
|
||||||
const res = render(
|
const res = render(
|
||||||
<DataInspector data={json} collapsed={false} expandRoot />,
|
<DataInspector data={json} collapsed={false} expandRoot />,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -225,8 +225,10 @@ test('test serialize and deserializeShallowObject function for non Object input'
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process.platform !== 'win32') {
|
// dates on windows don't support changed timezones
|
||||||
test('test makeObjectSerializable and deserializeShallowObject function for Date input', () => {
|
test.unix(
|
||||||
|
'test makeObjectSerializable and deserializeShallowObject function for Date input',
|
||||||
|
() => {
|
||||||
const date = new Date(2021, 1, 29, 10, 31, 7, 205);
|
const date = new Date(2021, 1, 29, 10, 31, 7, 205);
|
||||||
expect(makeShallowSerializable(date)).toMatchInlineSnapshot(`
|
expect(makeShallowSerializable(date)).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
@@ -237,8 +239,8 @@ if (process.platform !== 'win32') {
|
|||||||
expect(deserializeShallowObject(makeShallowSerializable(date))).toEqual(
|
expect(deserializeShallowObject(makeShallowSerializable(date))).toEqual(
|
||||||
date,
|
date,
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
}
|
);
|
||||||
|
|
||||||
test('test makeObjectSerializable and deserializeShallowObject function for Map of Sets', () => {
|
test('test makeObjectSerializable and deserializeShallowObject function for Map of Sets', () => {
|
||||||
const map = new Map([
|
const map = new Map([
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ module.exports = {
|
|||||||
'\\.(js|tsx?)$': '<rootDir>/scripts/jest-transform.js',
|
'\\.(js|tsx?)$': '<rootDir>/scripts/jest-transform.js',
|
||||||
},
|
},
|
||||||
setupFiles: ['<rootDir>/scripts/jest-setup.js'],
|
setupFiles: ['<rootDir>/scripts/jest-setup.js'],
|
||||||
|
setupFilesAfterEnv: ['<rootDir>/scripts/jest-setup-after.js'],
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'^flipper$': '<rootDir>/app/src',
|
'^flipper$': '<rootDir>/app/src',
|
||||||
'^flipper-plugin$': '<rootDir>/flipper-plugin/src',
|
'^flipper-plugin$': '<rootDir>/flipper-plugin/src',
|
||||||
|
|||||||
33
desktop/scripts/jest-setup-after.js
Normal file
33
desktop/scripts/jest-setup-after.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
// jest-setup-after will run after Jest has been initialized, so that it can be adapted.
|
||||||
|
|
||||||
|
const test = global.test;
|
||||||
|
if (!test) {
|
||||||
|
throw new Error('Failed jest test object');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This test will not be executed on Github / SandCastle,
|
||||||
|
* since, for example, it relies on precise timer reliability
|
||||||
|
*/
|
||||||
|
test.local = function local() {
|
||||||
|
const fn = process.env.SANDCASTLE || process.env.CI ? test.skip : test;
|
||||||
|
// eslint-disable-next-line
|
||||||
|
return fn.apply(null, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test will only run on non-windows machines
|
||||||
|
*/
|
||||||
|
test.unix = function local() {
|
||||||
|
const fn = process.platform === 'win32' ? test.skip : test;
|
||||||
|
// eslint-disable-next-line
|
||||||
|
return fn.apply(null, arguments);
|
||||||
|
};
|
||||||
1
desktop/types/index.d.ts
vendored
1
desktop/types/index.d.ts
vendored
@@ -26,3 +26,4 @@
|
|||||||
/// <reference path="nodejs.d.ts" />
|
/// <reference path="nodejs.d.ts" />
|
||||||
/// <reference path="npm-api.d.ts" />
|
/// <reference path="npm-api.d.ts" />
|
||||||
/// <reference path="openssl-wrapper.d.ts" />
|
/// <reference path="openssl-wrapper.d.ts" />
|
||||||
|
/// <reference path="jest-extensions.d.ts" />
|
||||||
|
|||||||
22
desktop/types/jest-extensions.d.ts
vendored
Normal file
22
desktop/types/jest-extensions.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare namespace jest {
|
||||||
|
interface It {
|
||||||
|
/**
|
||||||
|
* This test will not be executed on Github / SandCastle,
|
||||||
|
* since, for example, it relies on precise timer reliability
|
||||||
|
*/
|
||||||
|
local: jest.It;
|
||||||
|
/**
|
||||||
|
* This test will only run on non-windows machines
|
||||||
|
*/
|
||||||
|
unix: jest.It;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user