Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce failing test to recreate openai shim issue #113

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions test/fixtures/side-effects/core.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { kind as shimsKind } from "./shims.mjs";
export { shimsKind };
9 changes: 9 additions & 0 deletions test/fixtures/side-effects/registry.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export let kind = undefined;

export function setShims(shims) {
if (kind) {
throw new Error(`shims already set to ${kind}`);
}

kind = shims.kind;
}
5 changes: 5 additions & 0 deletions test/fixtures/side-effects/runtime.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function getRuntime() {
return {
kind: "node",
};
}
8 changes: 8 additions & 0 deletions test/fixtures/side-effects/shims.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as shims from "./registry.mjs";
import * as auto from "./runtime.mjs";

if (!shims.kind) {
shims.setShims(auto.getRuntime());
}

export * from "./registry.mjs";
4 changes: 4 additions & 0 deletions test/hook/side-effects.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as core from "../fixtures/side-effects/core.mjs";
import { strictEqual } from "assert";

strictEqual(core.shimsKind, "node");