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

Reliability: Flow types for tests (part 3) #278

Merged
merged 19 commits into from
Dec 12, 2024
55 changes: 55 additions & 0 deletions flow-typed/node/assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Missing flow types for node:assert
declare module "assert" {
declare class AssertionError extends Error {}
declare type AssertStrict = {
(value: any, message?: string): void;
ok(value: any, message?: string): void;
fail(message?: string | Error): void;
// deprecated since v10.15
// fail(actual: any, expected: any, message: string, operator: string): void;
equal(actual: any, expected: any, message?: string): void;
notEqual(actual: any, expected: any, message?: string): void;
deepEqual(actual: any, expected: any, message?: string): void;
notDeepEqual(actual: any, expected: any, message?: string): void;
throws(
block: Function,
error?: Function | RegExp | (err: any) => boolean,
message?: string
): void;
doesNotThrow(block: Function, message?: string): void;
ifError(value: any): void;
AssertionError: typeof AssertionError;
strict: AssertStrict;
...
}
declare module.exports: {
(value: any, message?: string): void,
ok(value: any, message?: string): void,
fail(message?: string | Error): void,
// deprecated since v10.15
// fail(actual: any, expected: any, message: string, operator: string): void,
equal(actual: any, expected: any, message?: string): void,
notEqual(actual: any, expected: any, message?: string): void,
deepEqual(actual: any, expected: any, message?: string): void,
notDeepEqual(actual: any, expected: any, message?: string): void,
strictEqual(actual: any, expected: any, message?: string): void,
notStrictEqual(actual: any, expected: any, message?: string): void,
deepStrictEqual(actual: any, expected: any, message?: string): void,
notDeepStrictEqual(actual: any, expected: any, message?: string): void,
throws(
block: Function,
error?: Function | RegExp | (err: any) => boolean,
message?: string
): void,
doesNotThrow(block: Function, message?: string): void,
rejects(
block: Function,
error?: Function | RegExp | (err: any) => boolean,
message?: string
): void;
ifError(value: any): void,
AssertionError: typeof AssertionError,
strict: AssertStrict;
...
}
}
10 changes: 5 additions & 5 deletions packages/core/integration-tests/test/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,10 @@ describe('bundler', function () {
]);

let assetBar = findAsset(b, 'bar.js');
if (!assetBar) return assert(false);
if (!assetBar) return assert.fail();

let assetC = findAsset(b, 'c.js');
if (!assetC) return assert(false);
if (!assetC) return assert.fail();

assert(
b
Expand Down Expand Up @@ -957,7 +957,7 @@ describe('bundler', function () {
.find(
(bundle) => !bundle.getMainEntry() && bundle.name.includes('runtime'),
);
if (!aManifestBundle) return assert(false);
if (!aManifestBundle) return assert.fail();

let bBundles = b
.getBundles()
Expand All @@ -970,7 +970,7 @@ describe('bundler', function () {
stop();
}
});
if (!aBundleManifestAsset) return assert(false);
if (!aBundleManifestAsset) return assert.fail();

let aBundleManifestAssetCode = await aBundleManifestAsset.getCode();

Expand Down Expand Up @@ -1333,7 +1333,7 @@ describe('bundler', function () {

// Asset should not be inlined
const index = b.getBundles().find((b) => b.name.startsWith('index'));
if (!index) return assert(false);
if (!index) return assert.fail();

const contents = overlayFS.readFileSync(index.filePath, 'utf8');
assert(
Expand Down
17 changes: 15 additions & 2 deletions packages/core/integration-tests/test/contentHashing.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';
import {
Expand Down Expand Up @@ -99,11 +100,19 @@ describe('content hashing', function () {
async () => {
let a = await _bundle(
path.join(__dirname, 'integration/hash-distDir/a/index.html'),
{sourceMaps: true},
{
defaultTargetOptions: {
sourceMaps: true,
},
},
);
let b = await _bundle(
path.join(__dirname, 'integration/hash-distDir/b/index.html'),
{sourceMaps: true},
{
defaultTargetOptions: {
sourceMaps: true,
},
},
);

let aBundles = a.getBundles();
Expand All @@ -113,7 +122,11 @@ describe('content hashing', function () {
assert.equal(bBundles.length, 2);

let aJS = aBundles.find((bundle) => bundle.type === 'js');
if (!aJS) return assert.fail();

let bJS = bBundles.find((bundle) => bundle.type === 'js');
if (!bJS) return assert.fail();

assert(/index\.[a-f0-9]*\.js/.test(path.basename(aJS.filePath)));
assert.equal(aJS.name, bJS.name);
},
Expand Down
3 changes: 1 addition & 2 deletions packages/core/integration-tests/test/globals.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';

Expand Down Expand Up @@ -58,7 +59,6 @@ describe('globals', function () {
it('when scope hoisting is disabled', async function () {
let bundleGraph = await bundle(path.join(dir, 'index.js'), {
defaultTargetOptions: {
context: 'browser',
shouldScopeHoist: false,
},
inputFS: overlayFS,
Expand All @@ -84,7 +84,6 @@ describe('globals', function () {
it.v2('when scope hoisting is enabled', async function () {
let bundleGraph = await bundle(path.join(dir, 'index.js'), {
defaultTargetOptions: {
context: 'browser',
shouldScopeHoist: true,
},
inputFS: overlayFS,
Expand Down
Loading
Loading