test: add failing test for storing data in custom userDataDir

Headless isn't closing gracefully, which sometimes causes data loss when Chrome closes before it finishes writing things to disk.

See https://crbug.com/771830

References #921
This commit is contained in:
JoelEinbinder 2017-10-05 17:08:35 -07:00 committed by Andrey Lushnikov
parent c225b93037
commit d3976cb0a5

View File

@ -121,6 +121,24 @@ describe('Puppeteer', function() {
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
rm(userDataDir);
}));
// Headless has issues shutting down gracefully
// @see https://crbug.com/771830
(headless ? xit : it)('userDataDir option should restore state', SX(async function() {
const userDataDir = fs.mkdtempSync(path.join(__dirname, 'test-user-data-dir'));
const options = Object.assign({userDataDir}, defaultBrowserOptions);
const browser = await puppeteer.launch(options);
const page = await browser.newPage();
await page.goto(EMPTY_PAGE);
await page.evaluate(() => localStorage.hey = 'hello');
await browser.close();
const browser2 = await puppeteer.launch(options);
const page2 = await browser2.newPage();
await page2.goto(EMPTY_PAGE);
expect(await page2.evaluate(() => localStorage.hey)).toBe('hello');
await browser2.close();
rm(userDataDir);
}));
});
describe('Puppeteer.connect', function() {
it('should work', SX(async function() {