-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Create a new console logger for each snapshot (#407)
* commit dist This will be reverted soon. Just so I can test on a fork without publishing anything (or dealing with symlinks). * test: Create memory leak test for logger util * test: Throw error when memory leak is detected * Update test script names, create console transport function * fix: file clean up in logger test * test: capture output * Code review feedback
- Loading branch information
Showing
4 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { expect } from 'chai' | ||
import { existsSync, unlinkSync } from 'fs' | ||
import { createFileLogger } from '../../src/utils/logger' | ||
import { captureStdErr } from '../helpers/stdout' | ||
|
||
describe('logger utils', () => { | ||
describe('createFileLogger', () => { | ||
const filesToCleanUp = [] as any | ||
|
||
afterEach(() => { | ||
if (filesToCleanUp) { | ||
filesToCleanUp.forEach((file: string) => { | ||
const filePath = `${process.cwd()}/${file}` | ||
if (!existsSync(filePath)) { return } | ||
|
||
unlinkSync(filePath) | ||
}) | ||
} | ||
}) | ||
|
||
it('does not leak memory', async () => { | ||
const output = await captureStdErr(() => { | ||
for (let index = 0; index < 600; index++) { | ||
const fileName = `test-file-${index}` | ||
createFileLogger(fileName) | ||
filesToCleanUp.push(fileName) | ||
} | ||
}) | ||
|
||
expect(output).to.equal('') | ||
}) | ||
}) | ||
}) |