8000 test(dateFile): fixed a potential test timing issue · wxqGitHub/log4js-node@551472c · GitHub
[go: up one dir, main page]

Skip to content

Commit 551472c

Browse files
author
Gareth Jones
committed
test(dateFile): fixed a potential test timing issue
1 parent 6d3984d commit 551472c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

test/tap/dateFileAppender-test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ test('../../lib/appenders/dateFile', (batch) => {
5555
logger.info('this should not be written to the file');
5656
logger.warn('this should be written to the file');
5757

58-
t.teardown(() => { removeFile('date-file-test.log'); });
59-
60-
fs.readFile(path.join(__dirname, 'date-file-test.log'), 'utf8', (err, contents) => {
61-
t.include(contents, `this should be written to the file${EOL}`);
62-
t.equal(contents.indexOf('this should not be written to the file'), -1);
63-
t.end();
58+
log4js.shutdown(() => {
59+
fs.readFile(path.join(__dirname, 'date-file-test.log'), 'utf8', (err, contents) => {
60+
t.include(contents, `this should be written to the file${EOL}`);
61+
t.equal(contents.indexOf('this should not be written to the file'), -1);
62+
t.end();
63+
});
6464
});
65+
66+
t.teardown(() => { removeFile('date-file-test.log'); });
6567
});
6668

6769
batch.test('configure with options.alwaysIncludePattern', (t) => {
@@ -96,13 +98,13 @@ test('../../lib/appenders/dateFile', (batch) => {
9698
t.teardown(() => { removeFile(`date-file-test${thisTime}`); });
9799

98100
// wait for filesystem to catch up
99-
setTimeout(() => {
101+
log4js.shutdown(() => {
100102
fs.readFile(path.join(__dirname, `date-file-test${thisTime}`), 'utf8', (err, contents) => {
101103
t.include(contents, 'this should be written to the file with the appended date');
102104
t.include(contents, 'this is existing data', 'should not overwrite the file on open (issue #132)');
103105
t.end();
104106
});
105-
}, 100);
107+
});
106108
});
107109

108110
batch.test('should flush logs on shutdown', (t) => {

0 commit comments

Comments
 (0)
0