Skip to content

Commit

Permalink
Merge pull request #216 from catdad/new-headless
Browse files Browse the repository at this point in the history
using new Chrome headless mode for tests (mostly because the annoying message, but also because it will be the default soon)
  • Loading branch information
catdad authored Nov 28, 2023
2 parents 79a5792 + 77113a5 commit 62a8e32
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit 62a8e32

Please sign in to comment.