Skip to content

Commit

Permalink
test(nx): add test for project?.targets?.build?.options?.tsConfig eac…
Browse files Browse the repository at this point in the history
…h step could be undefined
  • Loading branch information
NexZhu committed Dec 21, 2023
1 parent c9dc238 commit ad4aab1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
5 changes: 4 additions & 1 deletion libs/nx/src/__fixtures__/nx-project/proj2/project.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"name": "proj2"
"name": "proj2",
"targets": {
"build": {}
}
}
8 changes: 8 additions & 0 deletions libs/nx/src/__fixtures__/nx-project/proj3/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "proj3",
"targets": {
"build": {
"options": {}
}
}
}
10 changes: 10 additions & 0 deletions libs/nx/src/__fixtures__/nx-project/proj4/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "proj4",
"targets": {
"build": {
"options": {
"tsConfig": "proj4/tsconfig.json"
}
}
}
}
1 change: 1 addition & 0 deletions libs/nx/src/__fixtures__/nx-project/proj4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
27 changes: 26 additions & 1 deletion libs/nx/src/nx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('nx', () => {
beforeEach(() => {
jest
.spyOn(globby, 'globby')
.mockResolvedValue(['./proj1/project.json', './proj2/project.json']);
.mockResolvedValue(['./proj1/project.json', './proj2/project.json', './proj3/project.json', './proj4/project.json']);
});

it('should return all found nx projects', async () => {
Expand All @@ -142,6 +142,31 @@ describe('nx', () => {
name: 'proj2',
project: {
name: 'proj2',
targets: { build: {} }
},
}),
expect.objectContaining({
name: 'proj3',
project: {
name: 'proj3',
targets: {
build: {
options: {}
}
}
},
}),
expect.objectContaining({
name: 'proj4',
project: {
name: 'proj4',
targets: {
build: {
options: {
tsConfig: 'proj4/tsconfig.json'
}
}
}
},
}),
])
Expand Down

0 comments on commit ad4aab1

Please sign in to comment.