(mf, messages)
| 15 | |
| 16 | const write = promisify(fs.write); |
| 17 | async function getModule(mf, messages) { |
| 18 | const src = compileModule(mf, messages); |
| 19 | const options = { plugins: ['@babel/plugin-transform-modules-commonjs'] }; |
| 20 | const { code } = await babel.transformAsync(src, options); |
| 21 | const { cleanup, fd, path } = await tmp.file({ |
| 22 | dir: __dirname, |
| 23 | postfix: '.js' |
| 24 | }); |
| 25 | await write(fd, code, 0, 'utf8'); |
| 26 | try { |
| 27 | return require(path).default; |
| 28 | } finally { |
| 29 | cleanup(); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | describe('compileModule()', function () { |
| 34 | it('can compile an object of messages', async function () { |
no test coverage detected