microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
7b48f26eb8caae7ed9cc1a09249195dfed76fa76

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

test/debugger/jsDebugConfigAdapter.test.ts

73lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import assert = require("assert");
5import * as path from "path";
6import * as sinon from "sinon";
7import { JsDebugConfigAdapter } from "../../src/debugger/jsDebugConfigAdapter";
8import { RNPackageVersions } from "../../src/common/projectVersionHelper";
9import { AppLauncher } from "../../src/extension/appLauncher";
10// import { AppLauncher } from "../../src/extension/appLauncher";
11
12suite("jsDebugConfigAdapter", function () {
13 suite("sourceMapOverrideConfiguration", function () {
14 const version: RNPackageVersions = {
15 reactNativeVersion: "0.80.0",
16 reactNativeWindowsVersion: "",
17 reactNativeMacOSVersion: "",
18 };
19
20 let appLauncherStub: Sinon.SinonStub;
21 const projectPath = path.resolve(
22 __dirname,
23 "..",
24 "resources",
25 "newVersionReactNativeProject",
26 );
27
28 let nodeModulesRoot: string;
29
30 setup(() => {
31 appLauncherStub = sinon.stub(
32 AppLauncher,
33 "getNodeModulesRootByProjectPath",
34 (projectRoot: string) => nodeModulesRoot,
35 );
36
37 nodeModulesRoot = projectPath;
38 });
39
40 teardown(function () {
41 appLauncherStub.restore();
42 });
43
44 test("should get source map override path correctly when user have both extra arguments and existing arguments", async () => {
45 const attachArgs = {
46 cwd: projectPath,
47 port: 8081,
48 sourceMapPathOverrides: { testPath: "testNativePath" },
49 useHermesEngine: true,
50 webkitRangeMax: 9322,
51 webkitRangeMin: 9223,
52 reactNativeVersions: version,
53 platform: "android",
54 workspaceRoot: projectPath,
55 projectRoot: projectPath,
56 nodeModulesRoot: projectPath,
57 type: "reactnativedirect",
58 name: "Test attach",
59 request: "launch",
60 };
61 const attachConfiguration = await JsDebugConfigAdapter.createDebuggingConfigForRNHermes(
62 attachArgs,
63 8000,
64 "",
65 );
66 const expected = {
67 "/[metro-project]/*": `${projectPath}/*`,
68 testPath: "testNativePath",
69 };
70 assert.deepStrictEqual(attachConfiguration.sourceMapPathOverrides, expected);
71 });
72 });
73});
74