mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-25 01:49:06 -05:00
fix few problems found
This commit is contained in:
@@ -95,14 +95,19 @@ const runSmokeTest = (binaryDir: string, options: any): any => {
|
||||
const stdioOptions = _.extend({}, {
|
||||
env: {
|
||||
...process.env,
|
||||
...options.env,
|
||||
FORCE_COLOR: '0',
|
||||
},
|
||||
// execa defaults to extending process.env. We pass a fully-shaped env object
|
||||
// and need to prevent leaked parent vars (like ELECTRON_RUN_AS_NODE) from
|
||||
// being reintroduced after sanitization.
|
||||
extendEnv: false,
|
||||
timeout: options.smokeTestTimeout,
|
||||
})
|
||||
|
||||
// Sandboxed shells can leak ELECTRON_RUN_AS_NODE=1 into child processes.
|
||||
// Verify must run Electron in normal mode so --smoke-test/--ping are handled by Cypress.
|
||||
if (!process.env.CYPRESS_INTERNAL_FORCE_ELECTRON_RUN_AS_NODE) {
|
||||
if (!stdioOptions.env.CYPRESS_INTERNAL_FORCE_ELECTRON_RUN_AS_NODE) {
|
||||
delete stdioOptions.env.ELECTRON_RUN_AS_NODE
|
||||
}
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ describe('lib/tasks/verify', () => {
|
||||
expect(util.exec).toHaveBeenCalledWith(
|
||||
executablePath,
|
||||
['--no-sandbox', '--smoke-test', '--ping=222'],
|
||||
expect.objectContaining({ env: expect.objectContaining({ FORCE_COLOR: '0' }) }),
|
||||
expect.objectContaining({ env: expect.objectContaining({ FORCE_COLOR: '0' }), extendEnv: false }),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -431,10 +431,44 @@ describe('lib/tasks/verify', () => {
|
||||
executablePath,
|
||||
['--no-sandbox', '--smoke-test', '--ping=222'],
|
||||
expect.objectContaining({
|
||||
extendEnv: false,
|
||||
env: expect.not.objectContaining({ ELECTRON_RUN_AS_NODE: expect.anything() }),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps ELECTRON_RUN_AS_NODE when explicitly forced in child env options', async () => {
|
||||
createfs({
|
||||
alreadyVerified: false,
|
||||
executable: mockfs.file({ mode: 0o777 }),
|
||||
packageVersion,
|
||||
})
|
||||
|
||||
vi.mocked(util.exec).mockResolvedValue({
|
||||
stdout: '222',
|
||||
stderr: '',
|
||||
} as any)
|
||||
|
||||
await start({
|
||||
listrRenderer: 'silent',
|
||||
env: {
|
||||
ELECTRON_RUN_AS_NODE: '1',
|
||||
CYPRESS_INTERNAL_FORCE_ELECTRON_RUN_AS_NODE: '1',
|
||||
},
|
||||
})
|
||||
|
||||
expect(util.exec).toHaveBeenCalledWith(
|
||||
executablePath,
|
||||
['--no-sandbox', '--smoke-test', '--ping=222'],
|
||||
expect.objectContaining({
|
||||
extendEnv: false,
|
||||
env: expect.objectContaining({
|
||||
ELECTRON_RUN_AS_NODE: '1',
|
||||
CYPRESS_INTERNAL_FORCE_ELECTRON_RUN_AS_NODE: '1',
|
||||
}),
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with force: true', () => {
|
||||
|
||||
Reference in New Issue
Block a user