-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.js
More file actions
43 lines (38 loc) · 906 Bytes
/
test.js
File metadata and controls
43 lines (38 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import fs from 'fs'
import test from 'ava'
import path from 'path'
import webpack from 'webpack'
import memoryFs from 'memory-fs'
const testFixture = (fixture, options = {}) => {
const compiler = webpack({
entry: `./${fixture}`,
output: {
path: path.resolve(__dirname),
filename: 'bundle.js'
},
externals: {
'system-components': 'systemComponents'
},
module: {
rules: [
{
test: /fixture.json$/,
use: path.resolve(__dirname, './')
}
]
}
})
compiler.outputFileSystem = new memoryFs()
return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
if (err) reject(err)
resolve(stats)
})
})
}
test('returns components', async t => {
const stats = await testFixture('fixture.json')
const json = stats.toJson()
const src = json.modules[0].source
t.snapshot(src)
})