forked from Netcentric/fe-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.test.js
More file actions
36 lines (30 loc) · 1.2 KB
/
Copy pathwebpack.test.js
File metadata and controls
36 lines (30 loc) · 1.2 KB
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
const fs = require('fs');
const path = require('path');
const webpackTask = require('./webpack');
const defaults = require('../config');
const extendConfig = require('../utils/extendConfig');
const generateEntries = require('../utils/generateEntries');
let config = extendConfig('./test/.febuild', defaults);
let entries = {
...generateEntries(config, 'js')
};
const { destinationPath, projectKey } = config.general;
beforeAll(async () =>
await new Promise(async (r) => {
await webpackTask(config);
r();
})
);
describe('Test task/webpack.js', () => {
Object.keys(entries).forEach((entry) => {
const file = path.join(destinationPath, entry);
const source = entries[entry];
const ext = path.extname(file) === '.js' ? 'js' : 'css';
const fileName = `${file.split('.').slice(0, -1).join('.')}.${ext}`;
it(`Compile ${source} file and save ${entry} at destination folder`, async () => {
const bundleContent = fs.readFileSync(fileName, { encoding:'utf8', flag:'r' });
const sourceContent = fs.readFileSync(source, { encoding:'utf8', flag:'r' });
expect(bundleContent).not.toBe(sourceContent);
});
})
});