test: fix appveyour flakiness (#2779)

Crashpad sometimes prevents us from removing a folder in tests.

References #2778.
This commit is contained in:
Andrey Lushnikov 2018-06-20 13:52:36 -07:00 committed by GitHub
parent 4178b989d2
commit a460114945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,9 +15,9 @@
*/ */
const fs = require('fs'); const fs = require('fs');
const os = require('os'); const os = require('os');
const rm = require('rimraf').sync;
const path = require('path'); const path = require('path');
const {helper} = require('../lib/helper'); const {helper} = require('../lib/helper');
const rmAsync = helper.promisify(require('rimraf'));
const mkdtempAsync = helper.promisify(fs.mkdtemp); const mkdtempAsync = helper.promisify(fs.mkdtemp);
const readFileAsync = helper.promisify(fs.readFile); const readFileAsync = helper.promisify(fs.readFile);
const statAsync = helper.promisify(fs.stat); const statAsync = helper.promisify(fs.stat);
@ -57,7 +57,7 @@ module.exports.addTests = function({testRunner, expect, PROJECT_ROOT, defaultBro
expect(await browserFetcher.localRevisions()).toEqual(['123456']); expect(await browserFetcher.localRevisions()).toEqual(['123456']);
await browserFetcher.remove('123456'); await browserFetcher.remove('123456');
expect(await browserFetcher.localRevisions()).toEqual([]); expect(await browserFetcher.localRevisions()).toEqual([]);
rm(downloadsFolder); await rmAsync(downloadsFolder);
}); });
}); });
describe('AppMode', function() { describe('AppMode', function() {
@ -96,7 +96,8 @@ module.exports.addTests = function({testRunner, expect, PROJECT_ROOT, defaultBro
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
await browser.close(); await browser.close();
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
rm(userDataDir); // This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
await rmAsync(userDataDir).catch(e => {});
}); });
it('userDataDir argument', async({server}) => { it('userDataDir argument', async({server}) => {
const userDataDir = await mkdtempAsync(TMP_FOLDER); const userDataDir = await mkdtempAsync(TMP_FOLDER);
@ -106,7 +107,8 @@ module.exports.addTests = function({testRunner, expect, PROJECT_ROOT, defaultBro
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
await browser.close(); await browser.close();
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
rm(userDataDir); // This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
await rmAsync(userDataDir).catch(e => {});
}); });
it('userDataDir option should restore state', async({server}) => { it('userDataDir option should restore state', async({server}) => {
const userDataDir = await mkdtempAsync(TMP_FOLDER); const userDataDir = await mkdtempAsync(TMP_FOLDER);
@ -122,7 +124,8 @@ module.exports.addTests = function({testRunner, expect, PROJECT_ROOT, defaultBro
await page2.goto(server.EMPTY_PAGE); await page2.goto(server.EMPTY_PAGE);
expect(await page2.evaluate(() => localStorage.hey)).toBe('hello'); expect(await page2.evaluate(() => localStorage.hey)).toBe('hello');
await browser2.close(); await browser2.close();
rm(userDataDir); // This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
await rmAsync(userDataDir).catch(e => {});
}); });
it('userDataDir option should restore cookies', async({server}) => { it('userDataDir option should restore cookies', async({server}) => {
const userDataDir = await mkdtempAsync(TMP_FOLDER); const userDataDir = await mkdtempAsync(TMP_FOLDER);
@ -138,7 +141,8 @@ module.exports.addTests = function({testRunner, expect, PROJECT_ROOT, defaultBro
await page2.goto(server.EMPTY_PAGE); await page2.goto(server.EMPTY_PAGE);
expect(await page2.evaluate(() => document.cookie)).toBe('doSomethingOnlyOnce=true'); expect(await page2.evaluate(() => document.cookie)).toBe('doSomethingOnlyOnce=true');
await browser2.close(); await browser2.close();
rm(userDataDir); // This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
await rmAsync(userDataDir).catch(e => {});
}); });
it('should return the default chrome arguments', async() => { it('should return the default chrome arguments', async() => {
const args = puppeteer.defaultArgs(); const args = puppeteer.defaultArgs();