import chai, { expect } from 'chai'; import sinon from 'ts-sinon'; import sinonChai from 'sinon-chai'; chai.use(sinonChai); import { withDir } from 'tmp-promise'; import { existsSync, readFileSync } from 'fs'; import { LogWriter } from '../src/logWriter'; const config: LogWriter.Config = { name: 'logWirterTested', path: 'it will be set by tmp-promise', }; describe('test logWriter', function () { describe('constructor', function () { it('will test the constructor with a new file', async function () { await withDir( async (dir) => { const log_writer = new LogWriter({ ...config, ...{ path: dir.path + '/toto.log' }, }); expect(existsSync(dir.path + '/toto.log')).to.be.true; expect( readFileSync(dir.path + '/toto.log', { encoding: 'utf-8', }) ).to.match(/LogWriter is running\n+$/g); }, { unsafeCleanup: true } ); }); }); describe('received message', function () { it('will test the print function', function () {}); }); }); //presenter le projet . listener -> import sous forme de plugin