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

fix: CI workflow error & add separate reference files for different platforms #2633

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
run: REACT_VERSION=${{ matrix.react_version }} yarn test

e2e-node:
name: Run E2E tests (Node.js ${{ matrix.node_version }}; ${{ matrix.cjs_or_esm == 'cjs' ? 'CJS' : 'ESM' }})
name: Run E2E tests (Node.js ${{ matrix.node_version }}; ${{ matrix.cjs_or_esm == 'cjs' && 'CJS' || 'ESM' }})
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
5 changes: 4 additions & 1 deletion e2e/node-cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const fs = require('node:fs/promises');
const os = require('node:os');
const assert = require('node:assert');
const { test } = require('node:test');
const { jsx } = require('react/jsx-runtime');
const { Document, Page, Text, renderToBuffer } = require('@react-pdf/renderer');

const platform = os.platform();

const MyDocument = () =>
jsx(Document, {
children: jsx(Page, {
Expand All @@ -28,7 +31,7 @@ function removeMovingParts(buffer) {

test('rendering a PDF', async () => {
const bufferPromise = renderToBuffer(jsx(MyDocument, {}));
const referenceBufferPromise = fs.readFile('../reference.pdf');
const referenceBufferPromise = fs.readFile(`../reference-${platform}.pdf`);

const [buffer, referenceBuffer] = await Promise.all([
bufferPromise,
Expand Down
5 changes: 4 additions & 1 deletion e2e/node-esm/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import fs from 'node:fs/promises';
import os from 'node:os';
import assert from 'node:assert';
import { test } from 'node:test';
import { jsx } from 'react/jsx-runtime';
import { Document, Page, Text, renderToBuffer } from '@react-pdf/renderer';

const platform = os.platform();

const MyDocument = () =>
jsx(Document, {
children: jsx(Page, {
Expand All @@ -28,7 +31,7 @@ function removeMovingParts(buffer) {

test('rendering a PDF', async () => {
const bufferPromise = renderToBuffer(jsx(MyDocument, {}));
const referenceBufferPromise = fs.readFile('../reference.pdf');
const referenceBufferPromise = fs.readFile(`../reference-${platform}.pdf`);

const [buffer, referenceBuffer] = await Promise.all([
bufferPromise,
Expand Down
File renamed without changes.
Binary file added e2e/reference-linux.pdf
Binary file not shown.