test: make sure tests fail properly instead of timing out (#24316)

This commit is contained in:
Milan Burda 2020-07-01 00:10:36 +02:00 committed by GitHub
parent 451086d7f2
commit c6db47182a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1484 additions and 1367 deletions

View file

@ -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);
});
});