main
js 58 lines 1.56 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 import {exec} from 'child-process-promise';
11 import {readFileSync} from 'fs';
12 import path from 'path';
13 import {rimrafSync} from 'rimraf';
14
15 describe('ignoreList source map extension', () => {
16 jest.setTimeout(60 * 1000);
17
18 const pathToExtensionsPackage = path.resolve(__dirname, '..', '..');
19 const pathToChromeExtensionBuild = path.join(
20 pathToExtensionsPackage,
21 'chrome/build',
22 );
23 const pathToSourceMap = path.resolve(
24 pathToChromeExtensionBuild,
25 'unpacked/build/react_devtools_backend_compact.js.map',
26 );
27
28 afterAll(() => {
29 rimrafSync(pathToChromeExtensionBuild);
30 });
31
32 describe('for dev builds', () => {
33 it('should not ignore list anything', async () => {
34 await exec('yarn build:chrome:local', {
35 cwd: pathToExtensionsPackage,
36 });
37
38 const sourceMapJSON = readFileSync(pathToSourceMap);
39 const sourceMap = JSON.parse(sourceMapJSON);
40
41 const {ignoreList} = sourceMap;
42 expect(ignoreList).toEqual([]);
43 });
44 });
45
46 describe('for production builds', function () {
47 it('should include every source', async () => {
48 await exec('yarn build:chrome', {cwd: pathToExtensionsPackage});
49
50 const sourceMapJSON = readFileSync(pathToSourceMap);
51 const sourceMap = JSON.parse(sourceMapJSON);
52
53 const {sources, ignoreList} = sourceMap;
54
55 expect(sources.length).toBe(ignoreList.length);
56 });
57 });
58 });