Add experimental Bun test runner (#2353)

* Add experimental Bun test runner

* Add TypeScript export for Bun

* Clean up tests to prevent TypeScript build warnings

* Use Node.js 22 to run codegen

* Squash a couple TypeScript errors during tests

These are expected errors, to test edge cases for non-TS users

* Ignore Bun lockfile

* Drop unused index.ts

* Move unit test file list to tap config
This commit is contained in:
Josh Mock
2024-08-28 12:33:46 -05:00
committed by GitHub
parent 889fee2316
commit 9e08aaebe2
8 changed files with 155 additions and 123 deletions

View File

@ -205,7 +205,7 @@ test('With generic document', async t => {
}
const Connection = connection.buildMockConnection({
onRequest (opts) {
onRequest (_opts) {
return {
statusCode: 200,
body: {

View File

@ -24,7 +24,7 @@ import FakeTimers from '@sinonjs/fake-timers'
test('Basic', async t => {
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
@ -78,7 +78,7 @@ test('Multiple searches (inside async iterator)', t => {
t.plan(4)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
@ -161,7 +161,7 @@ test('Multiple searches (async iterator exits)', t => {
t.plan(4)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
@ -242,7 +242,7 @@ test('Multiple searches (async iterator exits)', t => {
test('Stop a msearch processor (promises)', async t => {
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
@ -272,7 +272,7 @@ test('Bad header', t => {
t.plan(1)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
@ -297,7 +297,7 @@ test('Bad body', t => {
t.plan(1)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
@ -321,7 +321,7 @@ test('Bad body', t => {
test('Retry on 429', async t => {
let count = 0
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
if (count++ === 0) {
return {
body: {
@ -384,7 +384,7 @@ test('Retry on 429', async t => {
test('Single search errors', async t => {
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
@ -419,7 +419,7 @@ test('Entire msearch fails', t => {
t.plan(2)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
statusCode: 500,
body: {
@ -454,7 +454,7 @@ test('Resolves the msearch helper', t => {
t.plan(1)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
@ -470,17 +470,17 @@ test('Resolves the msearch helper', t => {
m.then(
() => t.pass('called'),
e => t.fail('Should not fail')
_e => t.fail('Should not fail')
)
m.catch(e => t.fail('Should not fail'))
m.catch(_e => t.fail('Should not fail'))
})
test('Stop the msearch helper with an error', t => {
t.plan(3)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
@ -511,7 +511,7 @@ test('Multiple searches (concurrency = 1)', t => {
t.plan(4)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
@ -587,7 +587,7 @@ test('Flush interval', t => {
t.teardown(() => clock.uninstall())
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
@ -640,7 +640,7 @@ test('Flush interval - early stop', t => {
t.plan(2)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
@ -684,7 +684,7 @@ test('Stop should resolve the helper', t => {
t.plan(1)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: []
@ -709,7 +709,7 @@ test('Stop should resolve the helper (error)', t => {
t.plan(3)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: []

View File

@ -196,7 +196,7 @@ test('Scroll search (retry throws and maxRetries)', async t => {
const expectedAttempts = maxRetries + 1
let count = 0
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
count += 1
return { body: {}, statusCode: 429 }
}
@ -217,8 +217,7 @@ test('Scroll search (retry throws and maxRetries)', async t => {
})
try {
// @ts-expect-error
for await (const result of scrollSearch) { // eslint-disable-line
for await (const _result of scrollSearch) { // eslint-disable-line
t.fail('we should not be here')
}
} catch (err: any) {
@ -344,7 +343,7 @@ test('Should not retry if maxRetries = 0', async t => {
const expectedAttempts = 1
let count = 0
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
count += 1
return { body: {}, statusCode: 429 }
}
@ -365,8 +364,7 @@ test('Should not retry if maxRetries = 0', async t => {
})
try {
// @ts-expect-error
for await (const result of scrollSearch) { // eslint-disable-line
for await (const _result of scrollSearch) { // eslint-disable-line
t.fail('we should not be here')
}
} catch (err: any) {