diff --git a/packages/metro/src/JSTransformer/__tests__/Transformer-test.js b/packages/metro/src/JSTransformer/__tests__/Transformer-test.js index 043947cb..a6e2a664 100644 --- a/packages/metro/src/JSTransformer/__tests__/Transformer-test.js +++ b/packages/metro/src/JSTransformer/__tests__/Transformer-test.js @@ -34,6 +34,8 @@ describe('Transformer', function() { }; beforeEach(function() { + jest.resetModules(); + Cache = jest.fn(); Cache.prototype.get = jest.fn((a, b, c) => c()); @@ -54,15 +56,23 @@ describe('Transformer', function() { api[method] = jest.fn(); }); + api.transform.mockImplementation(() => { + return { + result: 'transformed(code)', + transformFileStartLogEntry: {}, + transformFileEndLogEntry: {}, + }; + }); + return api; }); }); - it('passes transform data to the worker farm when transforming', () => { + it('passes transform data to the worker farm when transforming', async () => { const transformOptions = {arbitrary: 'options'}; const code = 'arbitrary(code)'; - new Transformer(opts).transform( + await new Transformer(opts).transform( fileName, localPath, code, diff --git a/packages/metro/src/JSTransformer/index.js b/packages/metro/src/JSTransformer/index.js index b88ec83f..f5f4244f 100644 --- a/packages/metro/src/JSTransformer/index.js +++ b/packages/metro/src/JSTransformer/index.js @@ -99,7 +99,7 @@ module.exports = class Transformer { assetRegistryPath: string, ): Promise { try { - debug('Started ransforming file', filename); + debug('Started transforming file', filename); const data = await this._worker.transform( filename,