1 |
|
2 |
|
3 | import invariant from 'assert';
|
4 | import path from 'path';
|
5 | import nullthrows from 'nullthrows';
|
6 |
|
7 | import {createWorkerFarm} from '../';
|
8 | import AssetGraphBuilder from '../src/AssetGraphBuilder';
|
9 | import {resolveParcelConfig} from '../src/loadParcelConfig';
|
10 | import {DEFAULT_OPTIONS} from './utils';
|
11 |
|
12 | const FIXTURES_DIR = path.join(__dirname, 'fixtures');
|
13 | const CONFIG_DIR = path.join(FIXTURES_DIR, 'config');
|
14 |
|
15 | describe('AssetGraphBuilder', function() {
|
16 |
|
17 | this.timeout(20000);
|
18 |
|
19 | let config;
|
20 | let builder;
|
21 | let workerFarm;
|
22 |
|
23 | before(() => {
|
24 | workerFarm = createWorkerFarm();
|
25 | });
|
26 |
|
27 | after(async () => {
|
28 | await workerFarm.end();
|
29 | });
|
30 |
|
31 | beforeEach(async () => {
|
32 | config = nullthrows(
|
33 | await resolveParcelConfig(
|
34 | path.join(CONFIG_DIR, 'index'),
|
35 | DEFAULT_OPTIONS,
|
36 | ),
|
37 | ).config;
|
38 |
|
39 | builder = new AssetGraphBuilder();
|
40 | await builder.init({
|
41 | name: 'test',
|
42 | options: DEFAULT_OPTIONS,
|
43 | config,
|
44 | entries: ['./module-b'],
|
45 | workerFarm,
|
46 | });
|
47 | });
|
48 |
|
49 | it('creates an AssetGraphBuilder', () => {
|
50 | invariant(builder.assetGraph.nodes.has('entry_specifier:./module-b'));
|
51 | });
|
52 | });
|