Skip to content

test: improve clarity of test-async-local-storage-enable-disable.js \…

The last als.run() will reactivate the als, hence the test should test for getting the object, not undefined

Based on the Nodejs documentation

Disables the instance of AsyncLocalStorage. All subsequent calls to asyncLocalStorage.getStore() will return undefined until asyncLocalStorage.run() or asyncLocalStorage.enterWith() is called

The original test is doing

asyncLocalStorage.run(new Map(), () => {
        assert.notStrictEqual(asyncLocalStorage.getStore(), undefined);

The asyncLocalStorage.getStore() will return a Map, however, the test will pass as it is not strict.

As this is within a run(), we should test for asyncLocalStorage to return the store instead.

This will demonstrate a clearer purpose of the test.

Merge request reports

Loading