Skip to content

Commit c0c0cfa

Browse files
chore: disable editTemplate test on Node v20 (#2235)
1 parent acdcb2b commit c0c0cfa

File tree

1 file changed

+89
-69
lines changed

1 file changed

+89
-69
lines changed

packages/cli/src/commands/init/__tests__/editTemplate.test.ts

Lines changed: 89 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {
1111
validatePackageName,
1212
replaceNameInUTF8File,
1313
} from '../editTemplate';
14+
import semver from 'semver';
15+
16+
const skipIfNode20 = semver.major(process.version) === 20 ? test.skip : test;
1417

1518
const FIXTURE_DIR = path.resolve(
1619
__dirname,
@@ -44,7 +47,7 @@ afterEach(() => {
4447
fs.removeSync(testPath);
4548
});
4649

47-
test('should edit template', async () => {
50+
skipIfNode20('should edit template', async () => {
4851
jest.spyOn(process, 'cwd').mockImplementation(() => testPath);
4952

5053
await changePlaceholderInTemplate({
@@ -96,7 +99,7 @@ test('should edit template', async () => {
9699
).toMatchSnapshot();
97100
});
98101

99-
test('should edit template with custom title', async () => {
102+
skipIfNode20('should edit template with custom title', async () => {
100103
jest.spyOn(process, 'cwd').mockImplementation(() => testPath);
101104

102105
await changePlaceholderInTemplate({
@@ -140,25 +143,28 @@ describe('changePlaceholderInTemplate', () => {
140143
jest.resetAllMocks();
141144
});
142145

143-
test(`should produce a lowercased version of "${PROJECT_NAME}" in package.json "name" field`, async () => {
144-
await changePlaceholderInTemplate({
145-
projectName: PROJECT_NAME,
146-
placeholderName: PLACEHOLDER_NAME,
147-
});
148-
149-
const oldPackageJsonFile = fs.readFileSync(
150-
path.resolve(FIXTURE_DIR, 'package.json'),
151-
'utf8',
152-
);
153-
const newPackageJsonFile = fs.readFileSync(
154-
path.resolve(testPath, 'package.json'),
155-
'utf8',
156-
);
157-
158-
expect(
159-
snapshotDiff(oldPackageJsonFile, newPackageJsonFile, {contextLines: 1}),
160-
).toMatchSnapshot();
161-
});
146+
skipIfNode20(
147+
`should produce a lowercased version of "${PROJECT_NAME}" in package.json "name" field`,
148+
async () => {
149+
await changePlaceholderInTemplate({
150+
projectName: PROJECT_NAME,
151+
placeholderName: PLACEHOLDER_NAME,
152+
});
153+
154+
const oldPackageJsonFile = fs.readFileSync(
155+
path.resolve(FIXTURE_DIR, 'package.json'),
156+
'utf8',
157+
);
158+
const newPackageJsonFile = fs.readFileSync(
159+
path.resolve(testPath, 'package.json'),
160+
'utf8',
161+
);
162+
163+
expect(
164+
snapshotDiff(oldPackageJsonFile, newPackageJsonFile, {contextLines: 1}),
165+
).toMatchSnapshot();
166+
},
167+
);
162168
});
163169

164170
describe('replacePlaceholderWithPackageName', () => {
@@ -170,22 +176,25 @@ describe('replacePlaceholderWithPackageName', () => {
170176
jest.resetAllMocks();
171177
});
172178

173-
test(`should replace name in package.json with ${PACKAGE_NAME} value`, async () => {
174-
await replacePlaceholderWithPackageName({
175-
projectName: PROJECT_NAME,
176-
placeholderName: PLACEHOLDER_NAME,
177-
placeholderTitle: 'Test',
178-
packageName: PACKAGE_NAME,
179-
});
180-
const packageJsonFile = fs.readFileSync(
181-
path.resolve(testPath, 'package.json'),
182-
'utf8',
183-
);
184-
185-
expect(JSON.parse(packageJsonFile).name).toBe(PACKAGE_NAME);
186-
});
179+
skipIfNode20(
180+
`should replace name in package.json with ${PACKAGE_NAME} value`,
181+
async () => {
182+
await replacePlaceholderWithPackageName({
183+
projectName: PROJECT_NAME,
184+
placeholderName: PLACEHOLDER_NAME,
185+
placeholderTitle: 'Test',
186+
packageName: PACKAGE_NAME,
187+
});
188+
const packageJsonFile = fs.readFileSync(
189+
path.resolve(testPath, 'package.json'),
190+
'utf8',
191+
);
192+
193+
expect(JSON.parse(packageJsonFile).name).toBe(PACKAGE_NAME);
194+
},
195+
);
187196

188-
test('should update the bundle ID for iOS', async () => {
197+
skipIfNode20('should update the bundle ID for iOS', async () => {
189198
await replacePlaceholderWithPackageName({
190199
projectName: PROJECT_NAME,
191200
placeholderName: PLACEHOLDER_NAME,
@@ -204,45 +213,56 @@ describe('replacePlaceholderWithPackageName', () => {
204213
).toBeTruthy();
205214
});
206215

207-
test(`should rename Main component name for Android with ${PROJECT_NAME}`, async () => {
208-
await replacePlaceholderWithPackageName({
209-
projectName: PROJECT_NAME,
210-
placeholderName: PLACEHOLDER_NAME,
211-
placeholderTitle: 'Test',
212-
packageName: PACKAGE_NAME,
213-
});
214-
215-
const mainActivityFile = fs.readFileSync(
216-
path.resolve(
217-
testPath,
218-
'android',
219-
'com',
220-
PACKAGE_NAME,
221-
'MainActivity.java',
222-
),
223-
'utf8',
224-
);
225-
226-
expect(mainActivityFile.includes(`return "${PROJECT_NAME}"`)).toBeTruthy();
227-
});
216+
skipIfNode20(
217+
`should rename Main component name for Android with ${PROJECT_NAME}`,
218+
async () => {
219+
await replacePlaceholderWithPackageName({
220+
projectName: PROJECT_NAME,
221+
placeholderName: PLACEHOLDER_NAME,
222+
placeholderTitle: 'Test',
223+
packageName: PACKAGE_NAME,
224+
});
225+
226+
const mainActivityFile = fs.readFileSync(
227+
path.resolve(
228+
testPath,
229+
'android',
230+
'com',
231+
PACKAGE_NAME,
232+
'MainActivity.java',
233+
),
234+
'utf8',
235+
);
236+
237+
expect(
238+
mainActivityFile.includes(`return "${PROJECT_NAME}"`),
239+
).toBeTruthy();
240+
},
241+
);
228242
});
229243

230244
describe('validatePackageName', () => {
231-
test('should throw an error when package name contains only one segment', () => {
232-
expect(() => validatePackageName('example')).toThrowError(
233-
'The package name example is invalid. It should contain at least two segments, e.g. com.app',
234-
);
235-
});
245+
skipIfNode20(
246+
'should throw an error when package name contains only one segment',
247+
() => {
248+
expect(() => validatePackageName('example')).toThrowError(
249+
'The package name example is invalid. It should contain at least two segments, e.g. com.app',
250+
);
251+
},
252+
);
236253

237-
test('should throw an error when package name contains special characters other than dots', () => {
238-
expect(() => validatePackageName('com.organization.a@pp')).toThrowError(
239-
'The com.organization.a@pp package name is not valid. It can contain only alphanumeric characters and dots.',
240-
);
241-
});
254+
skipIfNode20(
255+
'should throw an error when package name contains special characters other than dots',
256+
() => {
257+
expect(() => validatePackageName('com.organization.a@pp')).toThrowError(
258+
'The com.organization.a@pp package name is not valid. It can contain only alphanumeric characters and dots.',
259+
);
260+
},
261+
);
242262
});
243263

244264
describe('replaceNameInUTF8File', () => {
245-
test('should replace string in utf8 file', async () => {
265+
skipIfNode20('should replace string in utf8 file', async () => {
246266
const pathToUtf8File = path.join(
247267
testPath,
248268
'ios',
@@ -266,7 +286,7 @@ describe('replaceNameInUTF8File', () => {
266286
expect(afterReplacement).toContain(textToReplace);
267287
});
268288

269-
test('should not replace string in utf8 file', async () => {
289+
skipIfNode20('should not replace string in utf8 file', async () => {
270290
const fsWriteFileSpy = jest.spyOn(fs, 'writeFile');
271291
const pathToUtf8File = path.join(
272292
testPath,

0 commit comments

Comments
 (0)