Skip to content

Commit 5003ee8

Browse files
committed
chore: fix tests
1 parent fca16a8 commit 5003ee8

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

meteor/jest.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ const path = require('path')
22

33
const commonConfig = {
44
modulePaths: ['<rootDir>/node_modules/'],
5-
moduleNameMapper: {},
5+
moduleNameMapper: {
6+
// Ensure libraries that would match the extension rule are still resolved
7+
'bignumber.js': 'bignumber.js',
8+
// Drop file extensions in imports
9+
'(.+)\\.js$': '$1',
10+
},
611
unmockedModulePathPatterns: ['/^imports\\/.*\\.jsx?$/', '/^node_modules/'],
712
globals: {},
813
moduleFileExtensions: ['ts', 'js', 'json'],

meteor/server/worker/worker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ async function logLine(msg: LogEntry): Promise<void> {
264264

265265
let worker: Promisify<IpcJobWorker> | undefined
266266
Meteor.startup(async () => {
267+
if (Meteor.isTest) return // Don't start the worker
268+
267269
if (Meteor.isDevelopment) {
268270
// Ensure meteor restarts when the _force_restart file changes
269271
try {

packages/corelib/src/__tests__/lib.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ describe('Lib', () => {
138138
// The stringification should trigger .toString() -> .toJSON() in UserError:
139139
const str = stringifyError(userError)
140140
expect(str).toMatch(/^UserError: /)
141-
expect(JSON.parse(str.replace('UserError: ', ''))).toMatchObject({
141+
142+
// This trim is not nice, but necessary to strip off some of the error wrapping. This shouldn't be done anywhere else, but we need to for this test
143+
let strTrimmed = str.slice('UserError: '.length)
144+
strTrimmed = strTrimmed.slice(0, strTrimmed.indexOf('}, Error:') + 1)
145+
expect(JSON.parse(strTrimmed)).toMatchObject({
142146
errorCode: 42,
143147
key: UserErrorMessage.ValidationFailed,
144148
userMessage: {

packages/webui/jest.config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
moduleFileExtensions: ['js', 'ts', 'tsx'],
99
moduleNameMapper: {
1010
'meteor/(.*)': '<rootDir>/src/meteor/$1',
11+
'(.+)\\.js$': '$1',
1112
},
1213
transform: {
1314
'^.+\\.(ts|tsx)$': [

0 commit comments

Comments
 (0)