-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for expo web metro bundler setup (#2025)
* Add unit test for expo web * Update
- Loading branch information
Showing
6 changed files
with
105 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for details. | ||
|
||
import * as assert from "assert"; | ||
import * as path from "path"; | ||
import { ReactNativeProjectHelper } from "../../../src/common/reactNativeProjectHelper"; | ||
import { FileSystem } from "../../../src/common/node/fileSystem"; | ||
|
||
suite("expoWeb", function () { | ||
test("should add expo web metro bundler in app.json if it's not existing", async () => { | ||
const projectPath = path.join(__dirname, "..", "..", "resources", "sampleExpoProject"); | ||
const launchArgs = { | ||
cwd: projectPath, | ||
}; | ||
|
||
const appJsonPath = path.join(launchArgs.cwd, "app.json"); | ||
const fs = new FileSystem(); | ||
const appJson = await fs.readFile(appJsonPath); | ||
const jsonString = JSON.stringify(appJson); | ||
assert.strictEqual(jsonString.includes("bundler") && jsonString.includes("metro"), false); | ||
|
||
await ReactNativeProjectHelper.UpdateMertoBundlerForExpoWeb(launchArgs); | ||
const newAppJson = await fs.readFile(appJsonPath); | ||
const newJsonString = JSON.stringify(newAppJson); | ||
assert.strictEqual( | ||
newJsonString.includes("bundler") && newJsonString.includes("metro"), | ||
true, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"expo": { | ||
"name": "sampleExpoProject", | ||
"slug": "sampleExpoProject", | ||
"version": "1.0.0", | ||
"orientation": "portrait", | ||
"icon": "./assets/icon.png", | ||
"userInterfaceStyle": "light", | ||
"splash": { | ||
"image": "./assets/splash.png", | ||
"resizeMode": "contain", | ||
"backgroundColor": "#ffffff" | ||
}, | ||
"assetBundlePatterns": [ | ||
"**/*" | ||
], | ||
"ios": { | ||
"supportsTablet": true | ||
}, | ||
"android": { | ||
"adaptiveIcon": { | ||
"foregroundImage": "./assets/adaptive-icon.png", | ||
"backgroundColor": "#ffffff" | ||
} | ||
}, | ||
"web": { | ||
"favicon": "./assets/favicon.png" | ||
}, | ||
"sdkVersion": "49.0.0" | ||
}, | ||
"name": "sampleExpoProject" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "sampleExpoProject", | ||
"version": "1.0.0", | ||
"main": "node_modules/expo/AppEntry.js", | ||
"scripts": { | ||
"start": "expo start", | ||
"android": "expo start --android", | ||
"ios": "expo start --ios", | ||
"web": "expo start --web" | ||
}, | ||
"dependencies": { | ||
"expo": "~49.0.7", | ||
"expo-status-bar": "~1.6.0", | ||
"react": "18.2.0", | ||
"react-native": "0.72.3", | ||
"react-native-web": "~0.19.6", | ||
"react-dom": "18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.20.0" | ||
}, | ||
"private": true | ||
} |