Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp-scripts test-unit-js node debugging #21631

Merged
merged 8 commits into from
Apr 24, 2020
Prev Previous commit
Next Next commit
Add tests for passing node args to spawnScript
  • Loading branch information
ajlende committed Apr 16, 2020
commit cd26cac2d5b1fcca5e9617eac005b77ab1fdedf7
26 changes: 26 additions & 0 deletions packages/scripts/utils/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ describe( 'utils', () => {
expect( console ).toHaveLogged();
} );

test( 'should pass inspect args to node', () => {
crossSpawnMock.mockReturnValueOnce( { status: 0 } );

expect( () =>
spawnScript( scriptName, [], [ '--inspect-brk' ] )
).toThrow( 'Exit code: 0.' );
expect( crossSpawnMock ).toHaveBeenCalledWith(
'node',
[ '--inspect-brk', expect.stringContaining( scriptName ) ],
{ stdio: 'inherit' }
);
} );

test( 'should pass script args to the script', () => {
crossSpawnMock.mockReturnValueOnce( { status: 0 } );

expect( () =>
spawnScript( scriptName, [ '--runInBand' ] )
).toThrow( 'Exit code: 0.' );
expect( crossSpawnMock ).toHaveBeenCalledWith(
'node',
[ expect.stringContaining( scriptName ), '--runInBand' ],
{ stdio: 'inherit' }
);
} );

test( 'should finish successfully when the script properly executed', () => {
crossSpawnMock.mockReturnValueOnce( { status: 0 } );

Expand Down