UNPKG

1.2 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(path.join(CONFIG_DIR, 'index'), DEFAULT_OPTIONS)
34 ).config;
35
36 builder = new AssetGraphBuilder();
37 await builder.init({
38 name: 'test',
39 options: DEFAULT_OPTIONS,
40 config,
41 entries: ['./module-b'],
42 workerFarm
43 });
44 });
45
46 it('creates an AssetGraphBuilder', () => {
47 invariant(builder.assetGraph.nodes.has('entry_specifier:./module-b'));
48 });
49});