Skip to content

Commit

Permalink
Debug JPEG conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Jan 21, 2025
1 parent 4690bb4 commit ca02a7f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ commands:
command: npm run test:coverage -- --ci --reporters=default --reporters=jest-junit <<#parameters.runInBand>>-i<</parameters.runInBand>><<^parameters.runInBand>>--maxWorkers=2<</parameters.runInBand>>
environment:
CHROME_DISABLE_GPU: 1 # Disable GPU acceleration to mitigate flaky tests
DEBUG: marp-cli:jpeg
JEST_JUNIT_CLASSNAME: '{filepath}'
JEST_JUNIT_OUTPUT_DIR: tmp/test-results
MARP_TEST_CI: 1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
- name: Jest
env:
CHROME_DISABLE_GPU: 1 # Disable GPU acceleration to mitigate flaky tests
DEBUG: marp-cli:jpeg
JEST_JUNIT_CLASSNAME: '{filepath}'
JEST_JUNIT_OUTPUT_DIR: tmp/test-results
MARP_TEST_CI: 1
Expand Down
8 changes: 7 additions & 1 deletion src/utils/jpeg.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import dbg from 'debug'
import { Browser } from '../browser/browser'
import { debug } from './debug'

const debug = dbg('marp-cli:jpeg')

export const png2jpegViaPuppeteer = async (
browser: Browser,
Expand All @@ -13,6 +15,8 @@ export const png2jpegViaPuppeteer = async (
waitUntil: ['domcontentloaded', 'networkidle0'],
})

debug('Evaluating JavaScript to convert PNG to JPEG')

const jpegDataURL = await page.evaluate(
async (pngUri, q, timeout) => {
/* c8 ignore start */
Expand Down Expand Up @@ -52,6 +56,8 @@ export const png2jpegViaPuppeteer = async (
browser.timeout
)

debug('Evaluated JavaScript to convert PNG to JPEG')

if (!jpegDataURL.startsWith('data:image/jpeg;base64,'))
throw new Error('Failed to convert PNG to JPEG')

Expand Down

0 comments on commit ca02a7f

Please sign in to comment.