Skip to content
Merged
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
23 changes: 12 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

jobs:
test:
Expand All @@ -16,12 +16,13 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run test
- run: npm run lint
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run test
- run: npm run check
- run: npm run lint
16 changes: 4 additions & 12 deletions index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, jest, test } from '@jest/globals';
import Replicate, { Prediction } from 'replicate';
import Replicate, { ApiError, Prediction } from 'replicate';
import nock from 'nock';
import fetch from 'cross-fetch';

Expand Down Expand Up @@ -37,14 +37,6 @@ describe('Replicate client', () => {
test('Throws error if no auth token is provided', () => {
const expected = 'Missing required parameter: auth'

expect(() => {
new Replicate({ auth: undefined });
}).toThrow(expected);

expect(() => {
new Replicate({ auth: null });
}).toThrow(expected);

expect(() => {
new Replicate({ auth: "" });
}).toThrow(expected);
Expand Down Expand Up @@ -156,7 +148,7 @@ describe('Replicate client', () => {
nock(BASE_URL)
.post('/predictions')
.reply(201, (_uri, body) => {
expect(body[ 'stream' ]).toBe(true);
expect((body as any).stream).toBe(true);
return body
})

Expand Down Expand Up @@ -200,8 +192,8 @@ describe('Replicate client', () => {
},
});
} catch (error) {
expect(error.response.status).toBe(400);
expect(error.message).toContain("Invalid input")
expect((error as ApiError).response.status).toBe(400);
expect((error as ApiError).message).toContain("Invalid input")
}
})
// Add more tests for error handling, edge cases, etc.
Expand Down
Loading