1- import { beforeEach , expect , test } from 'vitest'
1+ import { afterEach , beforeEach , expect , test , vi } from 'vitest'
22
33import { mockFileSystem } from '../../tests/mock-file-system.js'
44import { NodeFS } from '../node/file-system.js'
@@ -8,6 +8,10 @@ beforeEach((ctx) => {
88 ctx . fs = new NodeFS ( )
99} )
1010
11+ afterEach ( ( ) => {
12+ vi . unstubAllEnvs ( )
13+ } )
14+
1115test ( 'should detect Angular' , async ( { fs } ) => {
1216 const cwd = mockFileSystem ( {
1317 'package.json' : JSON . stringify ( { dependencies : { '@angular/cli' : '17.0.0' } } ) ,
@@ -66,3 +70,27 @@ test('should only install plugin on v17+', async ({ fs }) => {
6670 expect ( detected ?. [ 0 ] . build . directory ) . toBe ( 'dist/' )
6771 expect ( detected ?. [ 0 ] . plugins ) . toEqual ( [ ] )
6872} )
73+
74+ test ( 'should not install plugin when NETLIFY_ANGULAR_PLUGIN_SKIP is set' , async ( { fs } ) => {
75+ const cwd = mockFileSystem ( {
76+ 'package.json' : JSON . stringify ( { dependencies : { '@angular/cli' : '17.0.0' } } ) ,
77+ 'angular.json' : JSON . stringify ( {
78+ projects : {
79+ demo : {
80+ architect : {
81+ build : {
82+ builder : '@angular-devkit/build-angular:application' ,
83+ options : {
84+ outputPath : 'dist/demo' ,
85+ } ,
86+ } ,
87+ } ,
88+ } ,
89+ } ,
90+ } ) ,
91+ } )
92+ vi . stubEnv ( 'NETLIFY_ANGULAR_PLUGIN_SKIP' , 'true' )
93+ const detected = await new Project ( fs , cwd ) . detectFrameworks ( )
94+ expect ( detected ?. [ 0 ] . id ) . toBe ( 'angular' )
95+ expect ( detected ?. [ 0 ] . plugins ) . toHaveLength ( 0 )
96+ } )
0 commit comments