Skip to content

Commit

Permalink
Add webpack test
Browse files Browse the repository at this point in the history
  • Loading branch information
billytrend-cohere committed Jun 11, 2024
1 parent 9fbec44 commit 0528c06
Show file tree
Hide file tree
Showing 4 changed files with 435 additions and 20 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"jest-environment-jsdom": "29.7.0",
"@types/node": "17.0.33",
"prettier": "2.7.1",
"ts-loader": "^9.5.1",
"typescript": "4.6.4",
"@types/readable-stream": "^4.0.14"
"@types/readable-stream": "^4.0.14",
"webpack": "^5.91.0"
}
}
3 changes: 1 addition & 2 deletions src/aws-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Sha256 } from '@aws-crypto/sha256-js';
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
import { HttpRequest } from '@aws-sdk/protocol-http';
import { SignatureV4 } from '@aws-sdk/signature-v4';
import { assert } from 'console';
import { PassThrough, Readable } from 'readable-stream';
import { APIResponse, FetchFunction, Fetcher, fetcher } from './core';
import { readableStreamAsyncIterable } from './core/streaming-fetcher/Stream';
Expand Down Expand Up @@ -161,7 +160,7 @@ export const fetchOverride = (platform: AwsPlatform, {
}: AwsProps): FetchFunction => async (fetcherArgs: Fetcher.Args): Promise<APIResponse<any, Fetcher.Error>> => {
const endpoint = fetcherArgs.url.split('/').pop() as string;
const bodyJson = fetcherArgs.body as { model?: string, stream?: boolean };
assert(bodyJson.model, "model is required")
console.assert(bodyJson.model, "model is required")

const isStreaming = Boolean(bodyJson.stream);

Expand Down
29 changes: 29 additions & 0 deletions src/test/env.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { describe, test } from "@jest/globals";
import webpack from 'webpack';

describe("test env compatibility", () => {
test("webpack", (done) => {
webpack({
mode: "production",
entry: "./src/index.ts",
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},

}, (err, stats) => {
done();
console.log(stats?.toString())
expect(err).toBe(null);
expect(stats?.hasErrors()).toBe(false);
})
})
});
Loading

0 comments on commit 0528c06

Please sign in to comment.