test: make sure tests fail properly instead of timing out (#24316)
This commit is contained in:
parent
451086d7f2
commit
c6db47182a
20 changed files with 1484 additions and 1367 deletions
|
@ -209,21 +209,17 @@ describe('app module', () => {
|
|||
});
|
||||
|
||||
describe('app.requestSingleInstanceLock', () => {
|
||||
it('prevents the second launch of app', function (done) {
|
||||
it('prevents the second launch of app', async function () {
|
||||
this.timeout(120000);
|
||||
const appPath = path.join(fixturesPath, 'api', 'singleton');
|
||||
const first = cp.spawn(process.execPath, [appPath]);
|
||||
first.once('exit', code => {
|
||||
expect(code).to.equal(0);
|
||||
});
|
||||
await emittedOnce(first.stdout, 'data');
|
||||
// Start second app when received output.
|
||||
first.stdout.once('data', () => {
|
||||
const second = cp.spawn(process.execPath, [appPath]);
|
||||
second.once('exit', code => {
|
||||
expect(code).to.equal(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
const second = cp.spawn(process.execPath, [appPath]);
|
||||
const [code2] = await emittedOnce(second, 'exit');
|
||||
expect(code2).to.equal(1);
|
||||
const [code1] = await emittedOnce(first, 'exit');
|
||||
expect(code1).to.equal(0);
|
||||
});
|
||||
|
||||
it('passes arguments to the second-instance event', async () => {
|
||||
|
@ -1003,34 +999,28 @@ describe('app module', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('does not launch for argument following a URL', done => {
|
||||
it('does not launch for argument following a URL', async () => {
|
||||
const appPath = path.join(fixturesPath, 'api', 'quit-app');
|
||||
// App should exit with non 123 code.
|
||||
const first = cp.spawn(process.execPath, [appPath, 'electron-test:?', 'abc']);
|
||||
first.once('exit', code => {
|
||||
expect(code).to.not.equal(123);
|
||||
done();
|
||||
});
|
||||
const [code] = await emittedOnce(first, 'exit');
|
||||
expect(code).to.not.equal(123);
|
||||
});
|
||||
|
||||
it('launches successfully for argument following a file path', done => {
|
||||
it('launches successfully for argument following a file path', async () => {
|
||||
const appPath = path.join(fixturesPath, 'api', 'quit-app');
|
||||
// App should exit with code 123.
|
||||
const first = cp.spawn(process.execPath, [appPath, 'e:\\abc', 'abc']);
|
||||
first.once('exit', code => {
|
||||
expect(code).to.equal(123);
|
||||
done();
|
||||
});
|
||||
const [code] = await emittedOnce(first, 'exit');
|
||||
expect(code).to.equal(123);
|
||||
});
|
||||
|
||||
it('launches successfully for multiple URIs following --', done => {
|
||||
it('launches successfully for multiple URIs following --', async () => {
|
||||
const appPath = path.join(fixturesPath, 'api', 'quit-app');
|
||||
// App should exit with code 123.
|
||||
const first = cp.spawn(process.execPath, [appPath, '--', 'http://electronjs.org', 'electron-test://testdata']);
|
||||
first.once('exit', code => {
|
||||
expect(code).to.equal(123);
|
||||
done();
|
||||
});
|
||||
const [code] = await emittedOnce(first, 'exit');
|
||||
expect(code).to.equal(123);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue