Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using new Chrome headless mode for tests (mostly because the annoying message, but also because it will be the default soon) #216

Merged
merged 7 commits into from
Nov 28, 2023
18 changes: 10 additions & 8 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ const PORT = 9999;
const width = 500;
const height = 500;

const args = ['--disable-background-timer-throttling'];

// Docker-based CIs need this disabled
// https://github.com/Quramy/puppeteer-example/blob/c28a5aa52fe3968c2d6cfca362ec28c36963be26/README.md#with-docker-based-ci-services
const args = process.env.CI ? [
'--no-sandbox', '--disable-setuid-sandbox'
] : [];
const headless = process.env.CI ? true :
process.env['CONFETTI_SHOW'] ? false : true;
if (process.env.CI) {
args.push('--no-sandbox', '--disable-setuid-sandbox');
}

const headless = (process.env.CI || !('CONFETTI_SHOW' in process.env)) ? 'new' : false;

const mkdir = async (dir) => {
return promisify(fs.mkdir)(dir)
Expand Down Expand Up @@ -62,7 +64,7 @@ const testBrowser = (() => {

return puppeteer.launch({
headless,
args: [ '--disable-background-timer-throttling' ].concat(args)
args
}).then(thisBrowser => {
browser = thisBrowser;
return Promise.resolve(browser);
Expand Down Expand Up @@ -784,7 +786,7 @@ test('[text] shapeFromText can optionally render text in a requested color', asy
// this test renders a black canvas in a headless browser
// but works fine when it is not headless
// eslint-disable-next-line ava/no-skip-test
(headless ? test.skip : test)('[text] shoots confetti of an emoji shape', async t => {
test('[text] shoots confetti of an emoji shape', async t => {
const page = t.context.page = await fixturePage();

const fontFace = await loadFont(page);
Expand All @@ -803,7 +805,7 @@ test('[text] shapeFromText can optionally render text in a requested color', asy
});
t.context.image = await readImage(t.context.buffer);

t.is(t.context.image.hash(), '9CppCqpCmtC');
t.is(t.context.image.hash(), 'cPpcSrcCjdC');
});

/*
Expand Down