-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[no-issue]: Convert web-config-server tests to jest #4194
Changes from 5 commits
4df9c45
eba6efb
cdc2648
efb7424
5f9eaaa
0bfc0df
39e812d
882641d
b2d7f10
dae0003
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
const getPlugins = api => { | ||
if (api.env(['development', 'test'])) { | ||
return ['istanbul']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build-related change, should be fine |
||
} | ||
return []; | ||
}; | ||
|
||
const includedDateOffset = 90 * 24 * 60 * 60 * 1000; // include migrations up to 90 days old | ||
const includedMigrationsDate = new Date().setTime(Date.now() - includedDateOffset); | ||
const checkMigrationOutdated = function (migrationName) { | ||
|
@@ -46,7 +39,6 @@ const getIgnore = api => { | |
}; | ||
|
||
module.exports = function (api) { | ||
const plugins = getPlugins(api); | ||
const ignore = getIgnore(api); | ||
return { plugins, ignore }; | ||
return { ignore }; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
const baseConfig = require('../../jest.config-js.json'); | ||
|
||
const { coveragePathIgnorePatterns = [] } = baseConfig; | ||
|
||
module.exports = async () => ({ | ||
...baseConfig, | ||
rootDir: '.', | ||
coveragePathIgnorePatterns: [...coveragePathIgnorePatterns, '<rootDir>/src/migrations'], | ||
setupFilesAfterEnv: ['../../jest.setup.js', './jest.setup.js'], | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,5 @@ | |
} | ||
} | ||
] | ||
], | ||
"env": { | ||
"test": { | ||
"plugins": ["istanbul"] | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const baseConfig = require('../../jest.config-js.json'); | ||
|
||
module.exports = async () => ({ | ||
...baseConfig, | ||
rootDir: '.', | ||
moduleNameMapper: { | ||
'^/aggregator(.*)$': '<rootDir>/src/aggregator$1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find a way to generalise these (without more elaborate folder scanning logic). I also tried the following transformation. It throws an error because it is also applied to
|
||
'^/*apiV1(.*)$': '<rootDir>/src/apiV1$1', | ||
'^/app(.*)$': '<rootDir>/src/app$1', | ||
'^/appServer(.*)$': '<rootDir>/src/appServer$1', | ||
'^/authSession(.*)$': '<rootDir>/src/authSession$1', | ||
'^/connections(.*)$': '<rootDir>/src/connections$1', | ||
'^/dhis(.*)$': '<rootDir>/src/dhis$1', | ||
'^/export(.*)$': '<rootDir>/src/export$1', | ||
'^/models(.*)$': '<rootDir>/src/models$1', | ||
'^/preaggregation(.*)$': '<rootDir>/src/preaggregation$1', | ||
'^/utils(.*)$': '<rootDir>/src/utils$1', | ||
}, | ||
setupFilesAfterEnv: ['../../jest.setup.js', './jest.setup.js'], | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Tupaia | ||
* Copyright (c) 2017 - 2022 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
import { clearTestData, getTestDatabase } from '@tupaia/database'; | ||
|
||
import { getIsProductionEnvironment } from '/utils'; | ||
|
||
// These setup tasks need to be performed before any test, so we | ||
// do them in this file outside of any describe block. | ||
|
||
beforeAll(() => { | ||
const isProductionEnvironment = getIsProductionEnvironment(); | ||
if (isProductionEnvironment) { | ||
// Don't test on production | ||
throw new Error('Never run the test suite on the production server, it messes with data!'); | ||
kael89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}); | ||
|
||
afterAll(async () => { | ||
const database = getTestDatabase(); | ||
await clearTestData(database); | ||
await database.closeConnections(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that nobody was checking test coverage in JS packages for the last 14 months 😛