Skip to content

Commit

Permalink
Merge branch 'master' of github.com:flow-typed/flow-typed
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianzchen committed Mar 17, 2024
2 parents f7fd492 + 6ad7126 commit c2ec346
Show file tree
Hide file tree
Showing 12 changed files with 1,275 additions and 1,101 deletions.
56 changes: 56 additions & 0 deletions cli/flow-typed/npm/flow-copy-source_vx.x.x.js
@@ -0,0 +1,56 @@
// flow-typed signature: a8f715e1d07cad4c955b0fdba21d8172
// flow-typed version: <<STUB>>/flow-copy-source_v^2.0.9/flow_v0.165.1

/**
* This is an autogenerated libdef stub for:
*
* 'flow-copy-source'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'flow-copy-source' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'flow-copy-source/bin/flow-copy-source' {
declare module.exports: any;
}

declare module 'flow-copy-source/src' {
declare module.exports: any;
}

declare module 'flow-copy-source/src/kefir-copy-file' {
declare module.exports: any;
}

declare module 'flow-copy-source/src/kefir-glob' {
declare module.exports: any;
}

// Filename aliases
declare module 'flow-copy-source/bin/flow-copy-source.js' {
declare module.exports: $Exports<'flow-copy-source/bin/flow-copy-source'>;
}
declare module 'flow-copy-source/src/index' {
declare module.exports: $Exports<'flow-copy-source/src'>;
}
declare module 'flow-copy-source/src/index.js' {
declare module.exports: $Exports<'flow-copy-source/src'>;
}
declare module 'flow-copy-source/src/kefir-copy-file.js' {
declare module.exports: $Exports<'flow-copy-source/src/kefir-copy-file'>;
}
declare module 'flow-copy-source/src/kefir-glob.js' {
declare module.exports: $Exports<'flow-copy-source/src/kefir-glob'>;
}
@@ -1,7 +1,7 @@
// flow-typed signature: e79552dcbaf7786acff981b62cca0df0
// flow-typed version: 6912183195/jest_v27.x.x/flow_>=v0.134.x <=v0.200.x
// flow-typed signature: 553472410ab87c5fe8a2140e647f049d
// flow-typed version: 6912183195/jest_v29.x.x/flow_>=v0.134.x <=v0.200.x

type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
type JestMockFn<TArguments: $ReadOnlyArray<any>, TReturn> = {
(...args: TArguments): TReturn,
/**
* An object for introspecting mock calls
Expand All @@ -13,6 +13,12 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
* passed during the call.
*/
calls: Array<TArguments>,
/**
* An array containing the call arguments of the last call that was made
* to this mock function. If the function was not called, it will return
* undefined.
*/
lastCall: TArguments,
/**
* An array that contains all the object instances that have been
* instantiated from this mock function.
Expand Down Expand Up @@ -161,6 +167,32 @@ type JestPromiseType = {
*/
type JestTestName = string | Function;

type FakeableAPI =
| 'Date'
| 'hrtime'
| 'nextTick'
| 'performance'
| 'queueMicrotask'
| 'requestAnimationFrame'
| 'cancelAnimationFrame'
| 'requestIdleCallback'
| 'cancelIdleCallback'
| 'setImmediate'
| 'clearImmediate'
| 'setInterval'
| 'clearInterval'
| 'setTimeout'
| 'clearTimeout';

type FakeTimersConfig = {
advanceTimers?: boolean | number,
doNotFake?: Array<FakeableAPI>,
now?: number | Date,
timerLimit?: number,
legacyFakeTimers?: boolean,
...
};

/**
* Plugin: jest-styled-components
*/
Expand Down Expand Up @@ -919,7 +951,7 @@ type JestObjectType = {
* (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
* setImmediate and clearImmediate).
*/
useFakeTimers(mode?: 'modern' | 'legacy'): JestObjectType,
useFakeTimers(fakeTimersConfig?: FakeTimersConfig): JestObjectType,
/**
* Instructs Jest to use the real versions of the standard timer functions.
*/
Expand Down
3 changes: 1 addition & 2 deletions cli/package.json
Expand Up @@ -66,14 +66,13 @@
"eslint-plugin-prettier": "^4.0.0",
"flow-bin": "0.200.0",
"flow-copy-source": "^2.0.9",
"jest": "^27.3.1"
"jest": "^29.7.0"
},
"keywords": [
"flow",
"flowtype"
],
"jest": {
"name": "flow-typed-cli",
"modulePathIgnorePatterns": [
"<rootDir>/dist/.*",
"<rootDir>/node_modules/.*"
Expand Down
29 changes: 16 additions & 13 deletions cli/src/commands/__tests__/runTests-test.js
Expand Up @@ -9,29 +9,32 @@ import {
} from '../runTests';
import {path} from '../../lib/node';

const runTest = async (mockConsole: boolean) => {
if (mockConsole) {
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(false);
expect(status).toEqual(1);
});

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

const expectedError = `Unused suppression`;
const calls = ((console.log: any): JestMockFn<any, any>).mock.calls;
const lastErrorMsg = calls[calls.length - 1][1];
Expand Down
5 changes: 4 additions & 1 deletion cli/src/commands/runTests.js
Expand Up @@ -557,7 +557,10 @@ async function removeTrashFromBinDir() {
(await fs.readdir(path.join(BIN_DIR)))
.filter(name => !checkFlowFilename(name))
.forEach(async el => {
await fs.unlink(path.resolve(BIN_DIR, el));
const dir = path.resolve(BIN_DIR, el);
if (!fs.exists(dir)) {
await fs.unlink(dir);
}
});
}

Expand Down

0 comments on commit c2ec346

Please sign in to comment.