Skip to content

Commit

Permalink
Improve flaky tests about JPEG conversion
Browse files Browse the repository at this point in the history
Update `imageScale` option for testing to reduce memory usage.
  • Loading branch information
yhatt committed Jan 21, 2025
1 parent c21153a commit 5a37385
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ commands:
steps:
- run:
name: Jest
command: npm run test:coverage -- --ci --reporters=default --reporters=jest-junit <<# parameters.runInBand >>-i<</ parameters.runInBand >>
command: npm run test:coverage -- --ci --maxWorkers=2 --reporters=default --reporters=jest-junit <<# parameters.runInBand >>-i<</ parameters.runInBand >>
environment:
JEST_JUNIT_CLASSNAME: '{filepath}'
JEST_JUNIT_OUTPUT_DIR: tmp/test-results
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
MARP_TEST_CI: 1
run: >-
npm run test:coverage -- --ci --max-workers ${{ steps.cpu-cores.outputs.count }} --reporters=default --reporters=jest-junit ||
npm run test:coverage -- --ci --bail -i --reporters=default --reporters=jest-junit --no-cache ||
npm run test:coverage -- --ci --bail -i --reporters=default --reporters=jest-junit ||
npm run test:coverage -- --ci --bail -i --reporters=default --reporters=jest-junit --no-cache ||
npm run test:coverage -- --ci --bail -i --reporters=default --reporters=jest-junit --no-cache
Expand Down
22 changes: 11 additions & 11 deletions test/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1287,16 +1287,16 @@ describe('Converter', () => {
await instance({
output: 'b.jpg',
type: ConvertType.jpeg,
imageScale: 0.5,
imageScale: 0.25,
}).convertFile(new File(onePath))

expect(writeFileSpy.mock.calls[0][1]).toBeInstanceOf(Buffer)

const jpeg = writeFileSpy.mock.calls[0][1] as Buffer
const { width, height } = imageSize(jpeg)

expect(width).toBe(640)
expect(height).toBe(360)
expect(width).toBe(320)
expect(height).toBe(180)
},
timeoutLarge
)
Expand All @@ -1309,14 +1309,14 @@ describe('Converter', () => {
await using browserManager = new BrowserManager({
finders: ['chrome', 'edge'],
protocol: 'webDriverBiDi',
timeout,
timeout: timeoutLarge,
})

await instance({
browserManager,
output: 'b.jpg',
type: ConvertType.jpeg,
imageScale: 0.5,
imageScale: 0.25,
}).convertFile(new File(onePath))

const [lastCall] = writeFileSpy.mock.calls.slice(-1)
Expand All @@ -1325,8 +1325,8 @@ describe('Converter', () => {
const jpeg = lastCall[1] as Buffer
const { width, height } = imageSize(jpeg)

expect(width).toBe(640)
expect(height).toBe(360)
expect(width).toBe(320)
expect(height).toBe(180)

// Check JPEG quality is working
writeFileSpy.mockClear()
Expand All @@ -1353,14 +1353,14 @@ describe('Converter', () => {
async () => {
await using browserManager = new BrowserManager({
finders: ['firefox'],
timeout,
timeout: timeoutLarge,
})

await instance({
browserManager,
output: 'b.jpg',
type: ConvertType.jpeg,
imageScale: 0.5,
imageScale: 0.25,
}).convertFile(new File(onePath))

const [lastCall] = writeFileSpy.mock.calls.slice(-1)
Expand All @@ -1369,8 +1369,8 @@ describe('Converter', () => {
const jpeg = lastCall[1] as Buffer
const { width, height } = imageSize(jpeg)

expect(width).toBe(640)
expect(height).toBe(360)
expect(width).toBe(320)
expect(height).toBe(180)

// Check JPEG quality is working
writeFileSpy.mockClear()
Expand Down

0 comments on commit 5a37385

Please sign in to comment.