Skip to content

Commit

Permalink
Add running tests for Deno
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Jun 20, 2024
1 parent 0684c33 commit 91448b9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 2 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node_version:
- 14.17.0
- 14.17
- 16
- 18.0
- 18
Expand Down Expand Up @@ -138,3 +138,25 @@ jobs:
- run: npm ci
- run: npm run transpile
- run: bun test

test-deno:
name: Deno test
runs-on: ubuntu-latest
strategy:
matrix:
deno_version:
- 1.44

steps:
- uses: actions/checkout@v4
- name: Setup node ${{ env.PRIMARY_NODEJS_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.PRIMARY_NODEJS_VERSION }}
cache: "npm"
- name: Setup Deno ${{ matrix.deno_version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno_version }}
- run: npm ci
- run: deno task test:deno
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
/.nyc_output/
/.vscode/
/cjs/
/cjs-test/
/deno-tests/
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"test:cjs": "mocha --reporter progress cjs/*.test.cjs",
"test:e2e": "mocha --reporter progress test-e2e",
"test:dist": "mocha --reporter progress dist/test",
"test:deno": "node scripts/deno-adapt-test.js && mocha --reporter progress deno-tests/*.test.js",
"bundle-and-test": "npm run bundle && npm run test:dist",
"coverage": "c8 --reporter=lcovonly npm test",
"prepublishOnly": "npm run lint && npm run bundle && npm run transpile && npm run test:all"
Expand Down
11 changes: 11 additions & 0 deletions scripts/deno-adapt-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import fs from 'node:fs';

fs.rmSync('deno-tests', { recursive: true, force: true });
fs.mkdirSync('deno-tests');

for (const filename of fs.readdirSync('src')) {
const source = fs.readFileSync(`src/${filename}`, 'utf8')
.replace(/from '(assert|buffer|fs|stream|timers|util)'/g, 'from \'node:$1\'');

fs.writeFileSync(`deno-tests/${filename}`, source);
}
1 change: 1 addition & 0 deletions src/parse-chunked.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import assert from 'assert';
import { Buffer } from 'buffer'; // needed for Deno
import { Readable } from 'stream';
import { inspect } from 'util';
import { parseChunked } from './parse-chunked.js';
Expand Down
1 change: 1 addition & 0 deletions src/stringify-chunked.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import assert from 'assert';
import { inspect } from 'util';
import { setImmediate } from 'timers'; // needed for Deno
import { stringifyChunked } from './stringify-chunked.js';
import { date, allUtf8LengthDiffChars, tests, spaceTests, spaces, replacerTests } from './stringify-cases.js';

Expand Down
1 change: 1 addition & 0 deletions src/stringify-info.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import assert from 'assert';
import { Buffer } from 'buffer'; // needed for Deno
import { inspect } from 'util';
import { stringifyInfo } from './stringify-info.js';
import {
Expand Down

0 comments on commit 91448b9

Please sign in to comment.