File tree 3 files changed +9
-1
lines changed
packages/workspace/src/schematics/library
3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,6 @@ This library was generated with [Nx](https://nx.dev).
5
5
6
6
## Running unit tests
7
7
8
- Run ` ng test <%= name %>` to execute the unit tests via [ Jest] ( https://jestjs.io ) .
8
+ Run ` <%= cliCommand %> test <%= name %>` to execute the unit tests via [ Jest] ( https://jestjs.io ) .
9
9
10
10
<% } %>
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { Tree } from '@angular-devkit/schematics';
2
2
import { createEmptyWorkspace } from '@nrwl/workspace/testing' ;
3
3
import { readJsonInTree , updateJsonInTree } from '@nrwl/workspace' ;
4
4
import { NxJson } from '@nrwl/workspace' ;
5
+
5
6
import { runSchematic } from '../../utils/testing' ;
6
7
7
8
describe ( 'lib' , ( ) => {
@@ -98,9 +99,14 @@ describe('lib', () => {
98
99
99
100
it ( 'should generate files' , async ( ) => {
100
101
const tree = await runSchematic ( 'lib' , { name : 'myLib' } , appTree ) ;
102
+
101
103
expect ( tree . exists ( `libs/my-lib/jest.config.js` ) ) . toBeTruthy ( ) ;
102
104
expect ( tree . exists ( 'libs/my-lib/src/index.ts' ) ) . toBeTruthy ( ) ;
103
105
expect ( tree . exists ( 'libs/my-lib/src/lib/my-lib.ts' ) ) . toBeTruthy ( ) ;
106
+ expect ( tree . exists ( 'libs/my-lib/README.md' ) ) . toBeTruthy ( ) ;
107
+
108
+ const ReadmeContent = tree . readContent ( 'libs/my-lib/README.md' ) ;
109
+ expect ( ReadmeContent ) . toContain ( 'nx test my-lib' ) ;
104
110
} ) ;
105
111
} ) ;
106
112
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { formatFiles } from '@nrwl/workspace';
21
21
import { offsetFromRoot } from '@nrwl/workspace' ;
22
22
import { generateProjectLint , addLintFiles } from '../../utils/lint' ;
23
23
import { addProjectToNxJsonInTree , libsDir } from '../../utils/ast-utils' ;
24
+ import { cliCommand } from '../../core/file-utils' ;
24
25
25
26
export interface NormalizedSchema extends Schema {
26
27
name : string ;
@@ -74,6 +75,7 @@ function createFiles(options: NormalizedSchema): Rule {
74
75
template ( {
75
76
...options ,
76
77
...names ( options . name ) ,
78
+ cliCommand : cliCommand ( ) ,
77
79
tmpl : '' ,
78
80
offsetFromRoot : offsetFromRoot ( options . projectRoot ) ,
79
81
hasUnitTestRunner : options . unitTestRunner !== 'none' ,
You can’t perform that action at this time.
0 commit comments