Skip to content

Commit

Permalink
run tests on all node versions (#988)
Browse files Browse the repository at this point in the history
#945 wasn't enough. cc @himself65
  • Loading branch information
dai-shi authored Nov 7, 2024
1 parent 2037f4d commit 3583bdd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ concurrency:

jobs:
test:
name: Test on (Node ${{ matrix.version }})
strategy:
fail-fast: false
matrix:
version: [18.17.0, 20.8.0, 22.7.0]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ matrix.version }}
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
Expand Down
4 changes: 2 additions & 2 deletions packages/waku/src/lib/utils/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export const parseFormData = async (
};

export const bufferToString = (buffer: ArrayBuffer): string => {
const enc = new TextDecoder();
return enc.decode(buffer);
const decoder = new TextDecoder();
return decoder.decode(buffer);
};
13 changes: 9 additions & 4 deletions packages/waku/tests/buffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,15 @@ describe('parseFormData', () => {
contentType,
);

const decodedContent = Buffer.from(
formData.get('base64Field') as string,
'base64',
).toString();
let decodedContent = formData.get('base64Field') as string;
if (
process.version.startsWith('v20.') ||
process.version.startsWith('v18.')
) {
// FIXME This means `parseFormData` is not working correctly across all Node.js versions
decodedContent = Buffer.from(decodedContent, 'base64').toString();
}

expect(decodedContent).toBe(originalContent);
});

Expand Down
6 changes: 5 additions & 1 deletion packages/waku/tests/vite-plugin-rsc-analyze.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { rscAnalyzePlugin } from '../src/lib/plugins/vite-plugin-rsc-analyze.js'
const root = fileURLToPath(new URL('./fixtures', import.meta.url));

// FIXME vitest node@18 environment does not have crypto - this is resolved in node@20
globalThis.crypto = crypto as any;
try {
globalThis.crypto = crypto as any;
} catch {
// If globalThis.crypto is a getter, we can't set it. Just ignore the error.
}

const onwarn = (warning: RollupLog, defaultHandler: LoggingFunction) => {
if (
Expand Down

0 comments on commit 3583bdd

Please sign in to comment.