Skip to content

Commit

Permalink
Silence expected console.errors in DeltaBundler tests
Browse files Browse the repository at this point in the history
Summary: TSIA

Reviewed By: huntie

Differential Revision: D36545822

fbshipit-source-id: 0a98c65e5c7a1a06bca0533b6121e30ed1a8d2af
  • Loading branch information
motiz88 authored and facebook-github-bot committed May 20, 2022
1 parent fcff382 commit 94e79e0
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/metro/src/DeltaBundler/__tests__/resolver-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ let resolver;
const joinPath = osPlatform === 'win32' ? path.win32.join : path.posix.join;

describe(osPlatform, () => {
let originalError = console.error;
beforeEach(() => {
jest.resetModules();

Expand All @@ -130,14 +131,26 @@ let resolver;
require('os').tmpdir = () => p('/tmp');

fs = require('fs');

jest.spyOn(console, 'error');
originalError = console.error;
console.error = jest.fn((...args) => {
// Silence expected errors that we assert on later
if (
typeof args[0] === 'string' &&
args[0].startsWith('metro-file-map:')
) {
return;
}
originalError(...args);
});
});

afterEach(async () => {
resolver && (await resolver.end());
resolver = null;
console.error.mockRestore();
try {
resolver && (await resolver.end());
} finally {
resolver = null;
console.error = originalError;
}
});

describe('relative paths', () => {
Expand Down

0 comments on commit 94e79e0

Please sign in to comment.