Skip to content

Commit a050835

Browse files
Fix tests requiring package.json at the root of the project
As projectChangesService now checks the package.json at the root of the project, several tests are failing as they are mocking the project creation and there's no package.json at the specified place. Fix this by creating the package.json in the tests.
1 parent b40c92b commit a050835

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

test/platform-service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ function createTestInjector() {
4949
testInjector.register("nodeModulesBuilder", {
5050
prepareNodeModules: () => {
5151
return Promise.resolve();
52+
},
53+
prepareJSNodeModules: () => {
54+
return Promise.resolve();
5255
}
5356
});
5457
testInjector.register("pluginsService", {
@@ -382,6 +385,12 @@ describe('Platform Service Tests', () => {
382385

383386
let appDestFolderPath = path.join(tempFolder, "appDest");
384387
let appResourcesFolderPath = path.join(appDestFolderPath, "App_Resources");
388+
fs.writeJson(path.join(tempFolder, "package.json"), {
389+
name: "testname",
390+
nativescript: {
391+
id: "org.nativescript.testname"
392+
}
393+
});
385394

386395
return { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath };
387396
}

test/project-changes-service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ class ProjectChangesServiceTest extends BaseServiceTest {
3232
this.injector.register("devicePlatformsConstants", {});
3333
this.injector.register("projectChangesService", ProjectChangesService);
3434

35+
const fs = this.injector.resolve<IFileSystem>("fs");
36+
fs.writeJson(path.join(this.projectDir, Constants.PACKAGE_JSON_FILE_NAME), {
37+
nativescript: {
38+
id: "org.nativescript.test"
39+
}
40+
});
41+
3542
}
3643

3744
get projectChangesService(): IProjectChangesService {

0 commit comments

Comments
 (0)