1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const path = require('path')
|
13 | const { stdout, stderr } = require('stdout-stderr')
|
14 |
|
15 | process.on('unhandledRejection', error => {
|
16 | throw error
|
17 | })
|
18 |
|
19 |
|
20 | beforeEach(() => { stdout.start(); stderr.start(); stdout.print = true })
|
21 | afterEach(() => { stdout.stop(); stderr.stop() })
|
22 |
|
23 |
|
24 | global.n = p => path.normalize(p)
|
25 | global.r = p => path.resolve(p)
|
26 |
|
27 | global.assertDependencies = (fs, dependencies, devDependencies) => {
|
28 | expect(JSON.parse(fs.readFileSync('package.json').toString())).toEqual(expect.objectContaining({
|
29 | dependencies,
|
30 | devDependencies
|
31 | }))
|
32 | }
|
33 |
|
34 | global.assertNodeEngines = (fs, nodeEngines) => {
|
35 | expect(JSON.parse(fs.readFileSync('package.json').toString())).toEqual(expect.objectContaining({
|
36 | engines: { node: nodeEngines }
|
37 | }))
|
38 | }
|