Skip to content

Commit

Permalink
change way tests a run
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianzchen committed Mar 2, 2024
1 parent 146cb17 commit e32d767
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions cli/src/commands/__tests__/runTests-test.js
Expand Up @@ -2,29 +2,30 @@
import {run} from '../runTests';
import {path} from '../../lib/node';

const runTest = async () => {
jest.spyOn(console, 'log').mockImplementation(jest.fn());
const args = {
testPatterns: ['regression-1385_v1.x.x'],
numberOfFlowVersions: 2, // this can be reduced to 1 when latest flow release is not ignored
path: path.join(__dirname, '__runTests-fixtures__'),
};
return await run(args);
}

describe('run-tests (command)', () => {
describe('regression 1385', () => {
const origConsoleLog = console.log;
let status;
beforeEach(async () => {
(console: any).log = jest.fn();
const args = {
testPatterns: ['regression-1385_v1.x.x'],
numberOfFlowVersions: 2, //this can be reduced to 1 when latest flow release is not ignored
path: path.join(__dirname, '__runTests-fixtures__'),
};
status = await run(args);
}, 30000);

afterEach(() => {
(console: any).log = origConsoleLog;
jest.resetAllMocks();
});

it("returns error code if $FlowExpectedError test doesn't fail", async () => {
const status = await runTest();
expect(status).toEqual(1);
});

it('console logs about unused suppression', async () => {
await runTest();

const expectedError = `Unused suppression`;
const calls = ((console.log: any): JestMockFn<any, any>).mock.calls;
const lastErrorMsg = calls[calls.length - 1][1];
Expand Down

0 comments on commit e32d767

Please sign in to comment.