backend-test-utils: skip mock directory cleanup in CI
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -269,28 +269,6 @@ describe('createMockDirectory', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('cleanup', () => {
|
||||
let cleanupMockDir: MockDirectory;
|
||||
|
||||
describe('inner', () => {
|
||||
cleanupMockDir = createMockDirectory();
|
||||
|
||||
it('should populate a directory', () => {
|
||||
cleanupMockDir.setContent({
|
||||
'a.txt': 'a',
|
||||
});
|
||||
|
||||
expect(cleanupMockDir.content()).toEqual({
|
||||
'a.txt': 'a',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should clean up after itself automatically', () => {
|
||||
expect(cleanupMockDir.content()).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('tmpdir mock', () => {
|
||||
let tmpDirMock: MockDirectory;
|
||||
|
||||
|
||||
@@ -351,14 +351,20 @@ export function createMockDirectory(
|
||||
os.tmpdir = () => mocker.path;
|
||||
}
|
||||
|
||||
process.on('beforeExit', mocker.remove);
|
||||
// In CI we expect there to be no need to clean up temporary directories
|
||||
const needsCleanup = !process.env.CI;
|
||||
if (needsCleanup) {
|
||||
process.on('beforeExit', mocker.remove);
|
||||
}
|
||||
|
||||
try {
|
||||
afterAll(() => {
|
||||
if (origTmpdir) {
|
||||
os.tmpdir = origTmpdir;
|
||||
}
|
||||
mocker.remove();
|
||||
if (needsCleanup) {
|
||||
mocker.remove();
|
||||
}
|
||||
});
|
||||
} catch {
|
||||
/* ignore */
|
||||
|
||||
Reference in New Issue
Block a user