test: exit after app.relaunch is called (#28016)

This commit is contained in:
Cheng Zhao 2021-03-07 16:30:43 +09:00 committed by GitHub
parent f114dcfd6e
commit b3a0743121
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View file

@ -295,9 +295,9 @@ describe('app module', () => {
const child = cp.spawn(process.execPath, [appPath]);
child.stdout.on('data', (c) => console.log(c.toString()));
child.stderr.on('data', (c) => console.log(c.toString()));
child.on('exit', (code) => {
child.on('exit', (code, signal) => {
if (code !== 0) {
done(`Process exited with code ${code}`);
console.log(`Process exited with code "${code}" signal "${signal}"`);
}
});
});

View file

@ -152,13 +152,15 @@ describe('chrome extensions', () => {
const [, loadedExtension] = await loadedPromise;
const [, readyExtension] = await emittedOnce(customSession, 'extension-ready');
expect(loadedExtension).to.deep.equal(extension);
expect(readyExtension).to.deep.equal(extension);
// Compare JSON string to print more information if failed.
const expected = JSON.stringify(extension);
expect(JSON.stringify(loadedExtension)).to.equal(expected);
expect(JSON.stringify(readyExtension)).to.equal(expected);
const unloadedPromise = emittedOnce(customSession, 'extension-unloaded');
await customSession.removeExtension(extension.id);
const [, unloadedExtension] = await unloadedPromise;
expect(unloadedExtension).to.deep.equal(extension);
expect(JSON.stringify(unloadedExtension)).to.equal(expected);
});
it('lists loaded extensions in getAllExtensions', async () => {

View file

@ -14,10 +14,9 @@ app.whenReady().then(() => {
client.end(String(lastArg === '--second'));
});
client.once('end', () => {
if (lastArg !== '--second') {
app.relaunch({ args: process.argv.slice(1).concat('--second') });
}
app.exit(0);
});
if (lastArg !== '--second') {
app.relaunch({ args: process.argv.slice(1).concat('--second') });
}
});