Skip to content

Commit

Permalink
fix(expo): set port for e2e (#21559)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi authored Feb 2, 2024
1 parent cb3da6c commit 90d0453
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/expo/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export async function addE2e(
tree: Tree,
options: NormalizedSchema
): Promise<GeneratorCallback> {
const hasPlugin = hasExpoPlugin(tree);
const port = hasPlugin ? 8081 : 4200;
switch (options.e2eTestRunner) {
case 'cypress': {
const hasNxExportPlugin = hasExpoPlugin(tree);
Expand Down Expand Up @@ -46,8 +48,8 @@ export async function addE2e(
bundler: 'none',
skipFormat: true,
devServerTarget: `${options.projectName}:serve`,
port: 4200,
baseUrl: 'http://localhost:4200',
port,
baseUrl: `http://localhost:${port}`,
ciWebServerCommand: hasNxExportPlugin
? `nx run ${options.projectName}:serve-static`
: undefined,
Expand Down Expand Up @@ -77,7 +79,7 @@ export async function addE2e(
webServerCommand: `${getPackageManagerCommand().exec} nx serve ${
options.name
}`,
webServerAddress: 'http://localhost:4200',
webServerAddress: `http://localhost:${port}`,
rootProject: options.rootProject,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export default async function update(tree: Tree) {
let content = tree
.read(joinPathFragments(config.root, 'metro.config.js'))
.toString();
content = content.replace(/blockList: exclusionList(.+?(?=\n))/, '');
content = content.replace('// unstable_enableSymlinks: true,', '');
content = content.replace(
`blockList: exclusionList([/^(?!.*node_modules).*/dist/.*/]),`,
'// unstable_enablePackageExports: true,',
''
);
content = content.replace('unstable_enableSymlinks: true,', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export async function addE2e(
hasStyles: false,
unitTestRunner: 'none',
});
case 'detox':
case 'detox':
const { detoxApplicationGenerator } = ensurePackage<
typeof import('@nx/detox')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ async function addBundlerConfiguration(
typeof import('@nx/vite')
>('@nx/vite', nxVersion);
const viteTask = await viteConfigurationGenerator(tree, {
...normalizedSchema,
uiFramework: 'react',
project: normalizedSchema.project,
newProject: true,
Expand All @@ -111,6 +112,7 @@ async function addBundlerConfiguration(
typeof import('@nx/webpack')
>('@nx/webpack', nxVersion);
const webpackInitTask = await webpackInitGenerator(tree, {
...normalizedSchema,
skipFormat: true,
skipPackageJson: normalizedSchema.skipPackageJson,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export default async function update(tree: Tree) {
let content = tree
.read(joinPathFragments(config.root, 'metro.config.js'))
.toString();
content = content.replace(/blockList: exclusionList(.+?(?=\n))/, '');
content = content.replace('// unstable_enableSymlinks: true,', '');
content = content.replace(
`blockList: exclusionList([/^(?!.*node_modules).*/dist/.*/]),`,
'// unstable_enablePackageExports: true,',
''
);
content = content.replace('unstable_enableSymlinks: true,', '');
Expand Down

0 comments on commit 90d0453

Please sign in to comment.