Skip to content

Commit 809380d

Browse files
committed
add async test
1 parent d052f81 commit 809380d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

  • packages/babel-jest/src/__tests__

packages/babel-jest/src/__tests__/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jest.mock('../loadBabelConfig', () => {
1414

1515
return {
1616
loadPartialConfig: jest.fn((...args) => actual.loadPartialConfig(...args)),
17+
loadPartialConfigAsync: jest.fn((...args) =>
18+
actual.loadPartialConfigAsync(...args),
19+
),
1720
};
1821
});
1922

@@ -49,6 +52,25 @@ test('Returns source string with inline maps when no transformOptions is passed'
4952
expect(JSON.stringify(result.map!.sourcesContent)).toMatch('customMultiply');
5053
});
5154

55+
test('Returns source string with inline maps when no transformOptions is passed async', async () => {
56+
const result: any = await babelJest.processAsync!(
57+
sourceString,
58+
'dummy_path.js',
59+
{
60+
config: makeProjectConfig(),
61+
configString: JSON.stringify(makeProjectConfig()),
62+
instrument: false,
63+
},
64+
);
65+
expect(typeof result).toBe('object');
66+
expect(result.code).toBeDefined();
67+
expect(result.map).toBeDefined();
68+
expect(result.code).toMatch('//# sourceMappingURL');
69+
expect(result.code).toMatch('customMultiply');
70+
expect(result.map!.sources).toEqual(['dummy_path.js']);
71+
expect(JSON.stringify(result.map!.sourcesContent)).toMatch('customMultiply');
72+
});
73+
5274
describe('caller option correctly merges from defaults and options', () => {
5375
test.each([
5476
[

0 commit comments

Comments
 (0)