33 checkFilesExist ,
44 ensureNxProject ,
55 readFile ,
6+ readJson ,
67 runNxCommandAsync ,
78 uniq ,
89} from '@nrwl/nx-plugin/testing' ;
@@ -13,6 +14,8 @@ import { XmlDocument } from 'xmldoc';
1314
1415import { findProjectFileInPathSync } from '@nx-dotnet/utils' ;
1516
17+ const e2eDir = 'tmp/nx-e2e/proj' ;
18+
1619describe ( 'nx-dotnet e2e' , ( ) => {
1720 it ( 'should create apps, libs, and project references' , async ( ) => {
1821 const testApp = uniq ( 'app' ) ;
@@ -34,6 +37,42 @@ describe('nx-dotnet e2e', () => {
3437 expect ( output . stdout ) . toMatch ( / R e f e r e n c e .* a d d e d t o t h e p r o j e c t / ) ;
3538 } ) ;
3639
40+ it ( 'should work with affected' , async ( ) => {
41+ const testApp = uniq ( 'app' ) ;
42+ const testLib = uniq ( 'lib' ) ;
43+ ensureNxProject ( '@nx-dotnet/core' , 'dist/packages/core' ) ;
44+
45+ await runNxCommandAsync (
46+ `generate @nx-dotnet/core:app ${ testApp } --language="C#" --template="webapi"` ,
47+ ) ;
48+
49+ await runNxCommandAsync (
50+ `generate @nx-dotnet/core:lib ${ testLib } --language="C#" --template="classlib"` ,
51+ ) ;
52+
53+ await runNxCommandAsync (
54+ `generate @nx-dotnet/core:project-reference ${ testApp } ${ testLib } ` ,
55+ ) ;
56+
57+ const output = await runNxCommandAsync (
58+ 'print-affected --target build --base HEAD~1' ,
59+ ) ;
60+
61+ const depGraphCachePath = join (
62+ __dirname ,
63+ '../../../' ,
64+ e2eDir ,
65+ 'node_modules/.cache/nx/nxdeps.json' ,
66+ ) ;
67+
68+ const deps = readJson ( depGraphCachePath ) . nodes [ testApp ] . data . files . find (
69+ ( x : { ext : string ; deps : string [ ] } ) => x . ext === '.csproj' ,
70+ ) . deps ;
71+
72+ expect ( output . stderr ) . toBeFalsy ( ) ;
73+ expect ( deps ) . toContain ( testLib ) ;
74+ } , 150000 ) ;
75+
3776 describe ( 'nx g app' , ( ) => {
3877 it ( 'should obey dry-run' , async ( ) => {
3978 const app = uniq ( 'app' ) ;
@@ -73,7 +112,7 @@ describe('nx-dotnet e2e', () => {
73112 `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi"` ,
74113 ) ;
75114 const configFilePath = findProjectFileInPathSync (
76- join ( 'tmp/nx-e2e/proj/ apps', app ) ,
115+ join ( e2eDir , ' apps', app ) ,
77116 ) ;
78117 const config = readFileSync ( configFilePath ) . toString ( ) ;
79118 const projectXml = new XmlDocument ( config ) ;
0 commit comments