mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-22 06:57:49 +00:00
f586b7c9a8
When code that is unit tested is part of a file that imports modules which depend on the dbus module, this breaks the unit test environment because there is no system socket set up, as the unit test mocha config doesn't import fixtures.ts. For example, if we change src/compose/utils to import device-config or api-binder, both of those modules import lib/dbus which invokes a dbus.getBus call at the root level. This is problematic for unit testing. We can get around the root-level dbus.getBus call by initializing dbus only when it's first needed. The mocked-dbus test setup code can also be removed in favor of legacy mocha hooks, which makes the dbus stubbing in the legacy test environment more clear. We can remove these legacy hooks when all the legacy tests are migrated to unit/integration. Signed-off-by: Christina Ying Wang <christina@balena.io>
16 lines
449 B
JavaScript
16 lines
449 B
JavaScript
module.exports = {
|
|
bail: true, // Exit test script on first error
|
|
exit: true, // Force Mocha to exit after tests complete
|
|
recursive: true, // Look for tests in subdirectories
|
|
require: [
|
|
// Files to execute before running suites
|
|
'ts-node/register/transpile-only',
|
|
'tsconfig-paths/register',
|
|
'test/lib/chai.ts',
|
|
'test/legacy/fixtures.ts',
|
|
'test/lib/legacy-mocha-hooks.ts'
|
|
],
|
|
spec: ['test/legacy/**/*.spec.ts'],
|
|
timeout: '30000',
|
|
};
|