Skip to content

Commit ec1df80

Browse files
authored
Merge pull request #20366 from mozilla/fxa-13263
refactor(auth): migrate fxa-auth-server tests from sinon/proxyquire
2 parents 490bfe5 + 69e620d commit ec1df80

122 files changed

Lines changed: 14853 additions & 13349 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/fxa-auth-server/jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
preset: 'ts-jest',
77
testEnvironment: 'node',
88
rootDir: '.',
9+
modulePathIgnorePatterns: ['<rootDir>/dist/'],
910
testMatch: [
1011
'<rootDir>/lib/**/*.spec.ts',
1112
'<rootDir>/config/**/*.spec.ts',
@@ -29,7 +30,7 @@ module.exports = {
2930
maxWorkers: 4,
3031
clearMocks: true,
3132
workerIdleMemoryLimit: '512MB',
32-
setupFiles: ['<rootDir>/jest.setup.js', '<rootDir>/jest.setup-proxyquire.js'],
33+
setupFiles: ['<rootDir>/jest.setup.js', '<rootDir>/jest.setup-resolve.js'],
3334
testPathIgnorePatterns: ['\\.in\\.spec\\.ts$'],
3435
// Coverage configuration (enabled via --coverage flag)
3536
collectCoverageFrom: [

packages/fxa-auth-server/jest.setup-proxyquire.js renamed to packages/fxa-auth-server/jest.setup-resolve.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
/**
6-
* Fix for proxyquire not finding .ts files under Jest/ts-jest.
7-
* proxyquire uses resolve.sync() which defaults to only .js extensions.
6+
* Fix for module resolution not finding .ts files under Jest/ts-jest.
7+
* resolve.sync() defaults to only .js extensions, which breaks jest.mock()
8+
* for modules that resolve to .ts index files (e.g. fxa-shared/db/models/auth).
89
* This patches resolve.sync to also look for .ts files.
910
*/
1011

1112
const resolve = require('resolve');
1213
const originalSync = resolve.sync;
13-
resolve.sync = function(id, opts) {
14+
resolve.sync = function (id, opts) {
1415
opts = opts || {};
1516
if (!opts.extensions || opts.extensions.length === 0) {
1617
opts.extensions = ['.ts', '.tsx', '.js', '.json', '.node'];

0 commit comments

Comments
 (0)