balena-supervisor/test/lib
Felipe Lalanne 48e0733c7e Remove side effects for module imports
The supervisor uses the following pattern for async module
initialization

```typescript
// module.ts

export const initialised = (async () => {
    // do some async initialization
})();

// somewhere else
import * as module from 'module';

async function setup() {
  await module.initialise;
}
```

The above pattern means that whenever the module is imported, the
initialisation procedure will be ran, which is an anti-pattern.

This converts any instance of this pattern into a function

```typescript
export const initialised = _.once(async () => {
    // do some async initialization
});
```

And anywhere else on the code it replaces the call with a

```typescript
await module.initialised();
```

Change-type: patch
2022-09-06 15:48:18 -04:00
..
application-state-mock.ts Refactor test suite to use tsconfig paths 2022-08-18 13:05:10 -04:00
chai.ts Create test/unit and test/integration folders 2022-08-24 14:28:36 -04:00
db-helper.ts Remove side effects for module imports 2022-09-06 15:48:18 -04:00
errors.ts Update typed-error to 3.x 2020-08-19 10:07:54 +01:00
helpers.ts Add toggleable SUPERVISOR_HARDWARE_METRICS config 2021-05-13 13:59:07 +09:00
mocked-balena-api.ts api-binder: Convert to a singleton 2020-09-14 09:31:12 +01:00
mocked-database.ts Refactor test suite to use tsconfig paths 2022-08-18 13:05:10 -04:00
mocked-dbus.ts Better document mocked-dbus, add missing dbus interface methods 2022-06-09 11:41:50 -07:00
mocked-device-api.ts Remove side effects for module imports 2022-09-06 15:48:18 -04:00
mocked-dockerode.ts Fix mock dockerode module 2021-04-27 13:00:56 -04:00
mocked-iptables.ts Refactor test suite to use tsconfig paths 2022-08-18 13:05:10 -04:00
mockerode.ts Use tags to track supervised images in docker 2021-07-26 09:52:25 -04:00
prepare.ts Remove side effects for module imports 2022-09-06 15:48:18 -04:00