From 0684c33afd956c2a9a1587bbc944ed6e9c6ec5b9 Mon Sep 17 00:00:00 2001 From: Roman Dvornov Date: Thu, 20 Jun 2024 23:50:39 +0200 Subject: [PATCH] Add Bun test --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++----------- src/parse-chunked.test.js | 20 ++++++++-------- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b01a5e..f2fd99f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,19 +74,19 @@ jobs: - run: npm run bundle-and-test e2e-tests: - name: E2E tests - runs-on: ubuntu-latest - 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" - - run: npm ci - - run: npm run transpile - - run: npm run bundle - - run: npm run test:e2e + name: E2E tests + runs-on: ubuntu-latest + 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" + - run: npm ci + - run: npm run transpile + - run: npm run bundle + - run: npm run test:e2e unit-tests: name: Unit tests @@ -115,3 +115,26 @@ jobs: - run: npm run transpile - run: npm run test - run: npm run test:cjs + + test-bun: + name: Bun test + runs-on: ubuntu-latest + strategy: + matrix: + bun_version: + - 1.1.15 + + 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 Bun ${{ matrix.bun_version }} + uses: oven-sh/setup-bun@v1 + with: + bun-version: ${{ matrix.bun_version }} + - run: npm ci + - run: npm run transpile + - run: bun test diff --git a/src/parse-chunked.test.js b/src/parse-chunked.test.js index 6d078bc..fdbdb3c 100644 --- a/src/parse-chunked.test.js +++ b/src/parse-chunked.test.js @@ -130,43 +130,43 @@ describe('parseChunked()', () => { it('abs pos across chunks', () => assert.rejects( async () => await parse(['{"test":"he', 'llo",}']), - /(Unexpected token \}|Expected double-quoted property name) in JSON at position 16/ + /(Unexpected token \}|Expected double-quoted property name) in JSON at position 16|Property name must be a string literal/ ) ); it('abs pos across chunks #2', () => assert.rejects( async () => await parse(['[{"test":"hello"},', ',}']), - /Unexpected token , in JSON at position 18|Unexpected token ',', "\[,}" is not valid JSON$/ + /Unexpected token , in JSON at position 18|Unexpected token ','(, "\[,}" is not valid JSON)?$|/ ) ); it('abs pos across chunks #3 (whitespaces)', () => assert.rejects( async () => await parse(['[{"test" ', ' ', ' :"hello"} ', ' ', ',', ' ', ',}']), - /Unexpected token , in JSON at position 24|Unexpected token ',', "\[,}" is not valid JSON$/ + /Unexpected token , in JSON at position 24|Unexpected token ','(, "\[,}" is not valid JSON)?$/ ) ); it('should fail when starts with a comma', () => assert.rejects( async () => await parse([',{}']), - /Unexpected token , in JSON at position 0|Unexpected token ',', ",{}" is not valid JSON$/ + /Unexpected token , in JSON at position 0|Unexpected token ','(, ",{}" is not valid JSON)?$/ ) ); it('should fail when starts with a comma #2', () => assert.rejects( async () => await parse([',', '{}']), - /Unexpected token , in JSON at position 0|Unexpected token ',', ",{}" is not valid JSON/ + /Unexpected token , in JSON at position 0|Unexpected token ','(, ",{}" is not valid JSON)?$/ ) ); it('should fail when no comma', () => assert.rejects( async () => await parse(['[1 ', ' 2]']), - /(Unexpected number|Expected ',' or ']' after array element) in JSON at position 4/ + /(Unexpected number|Expected ',' or ']' after array element) in JSON at position 4|Expected ']'/ ) ); it('should fail when no comma #2', () => assert.rejects( async () => await parse(['[{}', '{}]']), - /(Unexpected token {|Expected ',' or ']' after array element) in JSON at position 3/ + /(Unexpected token {|Expected ',' or ']' after array element) in JSON at position 3|Expected ']'/ ) ); }); @@ -235,7 +235,7 @@ describe('parseChunked()', () => { yield '[1 '; yield '2]'; }), - /(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3/ + /(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3|Expected ']'/ ) ); @@ -267,7 +267,7 @@ describe('parseChunked()', () => { yield await Promise.resolve('[1 '); yield '2]'; }), - /(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3/ + /(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3|Expected ']'/ ) ); @@ -346,7 +346,7 @@ describe('parseChunked()', () => { it('with failure in JSON', () => assert.rejects( () => parseChunked(createReadableNodejsStream(['[1 ', '2]'])), - /(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3/ + /(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3|Expected ']'/ ) );