Skip to content

Commit

Permalink
chore: skip non-deterministic tests during recording
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalins committed Oct 6, 2022
1 parent 77d3f14 commit 2a5b889
Showing 1 changed file with 43 additions and 33 deletions.
76 changes: 43 additions & 33 deletions packages/@jsii/kernel/src/kernel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ defineTest.skip = function (
return defineTest(name, method, test.skip);
};

defineTest.skipIf = function (expr: boolean): typeof defineTest.skip {
return expr ? defineTest.skip : defineTest;
};

// Note: this test asserts file permissions, which work differently on Windows, so we skip it there
(process.platform === 'win32' ? test.skip : test)(
'load preserves file permissions',
Expand Down Expand Up @@ -2138,42 +2142,48 @@ defineTest('Override transitive property', (sandbox) => {
expect(propValue).toBe('N3W');
});

defineTest('getBinScriptCommand() returns output', (sandbox) => {
const result = sandbox.getBinScriptCommand({
assembly: 'jsii-calc',
script: 'calc',
});
defineTest.skipIf(!!recordingOutput)(
'getBinScriptCommand() returns output',
(sandbox) => {
const result = sandbox.getBinScriptCommand({
assembly: 'jsii-calc',
script: 'calc',
});

expect(result).toMatchObject<api.GetScriptCommandResponse>({
command: expect.stringMatching(
/node_modules[/\\]jsii-calc[/\\]bin[/\\]run$/,
),
args: [],
env: {
NODE_OPTIONS: expect.any(String),
PATH: expect.any(String),
},
});
});
expect(result).toMatchObject<api.GetScriptCommandResponse>({
command: expect.stringMatching(
/node_modules[/\\]jsii-calc[/\\]bin[/\\]run$/,
),
args: [],
env: {
NODE_OPTIONS: expect.any(String),
PATH: expect.any(String),
},
});
},
);

defineTest('getBinScriptCommand() accepts arguments', (sandbox) => {
const result = sandbox.getBinScriptCommand({
assembly: 'jsii-calc',
script: 'calc',
args: ['arg1', 'arg2'],
});
defineTest.skipIf(!!recordingOutput)(
'getBinScriptCommand() accepts arguments',
(sandbox) => {
const result = sandbox.getBinScriptCommand({
assembly: 'jsii-calc',
script: 'calc',
args: ['arg1', 'arg2'],
});

expect(result).toMatchObject<api.GetScriptCommandResponse>({
command: expect.stringMatching(
/node_modules[/\\]jsii-calc[/\\]bin[/\\]run$/,
),
args: ['arg1', 'arg2'],
env: {
NODE_OPTIONS: expect.any(String),
PATH: expect.any(String),
},
});
});
expect(result).toMatchObject<api.GetScriptCommandResponse>({
command: expect.stringMatching(
/node_modules[/\\]jsii-calc[/\\]bin[/\\]run$/,
),
args: ['arg1', 'arg2'],
env: {
NODE_OPTIONS: expect.any(String),
PATH: expect.any(String),
},
});
},
);

defineTest('invokeBinScript() return output', (sandbox) => {
const result = sandbox.invokeBinScript({
Expand Down

0 comments on commit 2a5b889

Please sign in to comment.