File tree Expand file tree Collapse file tree 2 files changed +30
-6
lines changed
lib/buildtools/src/build/modules/__tests__ Expand file tree Collapse file tree 2 files changed +30
-6
lines changed Original file line number Diff line number Diff line change 4444 run : yarn install --immutable
4545 shell : bash
4646
47- - name : Echo?
48- run : echo "${{ inputs.playwright == 'true' && inputs.install-deps == 'true'}}"
49- shell : bash
50-
5147 - name : Install Playwright
5248 if : inputs.playwright == 'true' && inputs.install-deps == 'true'
53- run : yarn playwright install --with-deps
49+ run : yarn workspaces foreach -A --include ${{ inputs.package-name }} run playwright install --with-deps
5450 shell : bash
Original file line number Diff line number Diff line change @@ -13,6 +13,23 @@ vi.spyOn(fs, 'open').mockResolvedValue({
1313 close : vi . fn ( )
1414} as any ) ;
1515
16+ vi . mock ( import ( 'esbuild' ) , async importOriginal => {
17+ // Add modules-lib to the list of external packages since it might
18+ // not be installed during a buildtools test run
19+ const original = await importOriginal ( ) ;
20+ return {
21+ ...original ,
22+ build : options => {
23+ options . external ! . push ( '@sourceacademy/modules-lib' ) ;
24+ return original . build ( options ) ;
25+ } ,
26+ context : options => {
27+ options . external ! . push ( '@sourceacademy/modules-lib' ) ;
28+ return original . context ( options ) ;
29+ }
30+ } ;
31+ } ) ;
32+
1633beforeEach ( ( ) => {
1734 written . splice ( 0 , written . length ) ;
1835} ) ;
@@ -63,10 +80,21 @@ test('build tab', async () => {
6380 } ) ;
6481 expect ( fs . open ) . toHaveBeenCalledWith ( '/build/tabs/tab0.js' , 'w' ) ;
6582
83+ function mockRequire ( path : string ) {
84+ console . log ( path ) ;
85+ if ( path === '@sourceacademy/modules-lib/tabs/utils' ) {
86+ return {
87+ defineTab : ( x : any ) => x
88+ } ;
89+ }
90+
91+ return { } ;
92+ }
93+
6694 const data = written . join ( '' ) ;
6795 const trimmed = ( data as string ) . slice ( 'export default' . length ) ;
6896
69- const { default : tab } = eval ( trimmed ) ( ( ) => { } ) ;
97+ const { default : tab } = eval ( trimmed ) ( mockRequire ) ;
7098 expect ( tab . body ( 0 ) ) . toEqual ( 0 ) ;
7199 expect ( tab . toSpawn ( ) ) . toEqual ( true ) ;
72100} ) ;
You can’t perform that action at this time.
0 commit comments