Skip to content

Commit

Permalink
chore: add tests to wrap/typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
dOrgJelli committed Sep 7, 2023
1 parent 04f2071 commit 7419b56
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/templates/tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe("Templates", () => {
},
"wasm/typescript": {
codegen: "yarn codegen",
build: "yarn build"
build: "yarn build",
test: "yarn test",
},
"plugin/rust": {
codegen: "npx polywrap codegen",
Expand Down
15 changes: 15 additions & 0 deletions packages/templates/wasm/typescript/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
collectCoverage: false,
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/**/?(*.)+(spec|test).[jt]s?(x)"],
globals: {
"ts-jest": {
tsconfig: "tsconfig.json",
diagnostics: false,
},
},
testPathIgnorePatterns: [
"/.polywrap/"
],
};
9 changes: 6 additions & 3 deletions packages/templates/wasm/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
"bundle": "rollup -c",
"codegen": "polywrap codegen --verbose",
"build": "yarn bundle && npx polywrap build --no-codegen",
"test": "jest --passWithNoTests --runInBand --verbose",
"deploy": "polywrap deploy"
},
"dependencies": {
"tslib": "^2.6.2"
},
"devDependencies": {
"polywrap": "~0.11.3",
"typescript": "^5.1.6",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-node-resolve": "^15.2.0",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.2",
"rollup": "^3.28.0"
"@types/jest": "26.0.8",
"jest": "26.6.3",
"polywrap": "~0.11.3",
"rollup": "^3.28.0",
"typescript": "^5.1.6"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { PolywrapClient } from "@polywrap/client-js";
import path from "path";

jest.setTimeout(60000);

describe("Template Wrapper End to End Tests", () => {

const client: PolywrapClient = new PolywrapClient();
let wrapUri = `file://${path.join(__dirname, "../../build")}`;

it("invoke foo", async () => {
const result = await client.invoke({
uri: wrapUri,
method: "foo",
args: { bar: "bar" }
});

expect(result.ok).toBeFalsy();
if (result.ok) return;
expect(result.error?.toString()).toContain("Not implemented");
});
});
7 changes: 5 additions & 2 deletions packages/templates/wasm/typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"lib": ["es2020", "dom"],
"lib": ["es2020"],
"importHelpers": true,
"downlevelIteration": true,
"experimentalDecorators": true,
Expand All @@ -22,5 +22,8 @@
"resolveJsonModule": true,
"strictNullChecks": true,
},
"include": ["./src/**/*.ts"]
"include": ["./src/**/*.ts"],
"exclude": [
"./src/__tests__/**/*.ts"
]
}

0 comments on commit 7419b56

Please sign in to comment.