UNPKG

1.23 kBJavaScriptView Raw
1// @flow strict-local
2
3import invariant from 'assert';
4import path from 'path';
5import nullthrows from 'nullthrows';
6
7import {createWorkerFarm} from '../';
8import AssetGraphBuilder from '../src/AssetGraphBuilder';
9import {resolveParcelConfig} from '../src/loadParcelConfig';
10import {DEFAULT_OPTIONS} from './utils';
11
12const FIXTURES_DIR = path.join(__dirname, 'fixtures');
13const CONFIG_DIR = path.join(FIXTURES_DIR, 'config');
14
15describe('AssetGraphBuilder', function() {
16 // This depends on spinning up a WorkerFarm, which can take some time.
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});