Skip to content

Commit

Permalink
Revert "Mock p2 package in e2e test by looking at package.json"
Browse files Browse the repository at this point in the history
This reverts commit 54ff9a7.
  • Loading branch information
kateinoigakukun committed Sep 8, 2024
1 parent f68f037 commit 5b51997
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/npm-packages/ruby-wasm-wasi/test-e2e/support.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BrowserContext, Page, expect } from "@playwright/test";
import { readFileSync } from "fs";
import path from "path";

export const waitForRubyVM = async (page: Page) => {
Expand All @@ -19,19 +18,14 @@ export const setupDebugLog = (context: BrowserContext) => {
};

export const setupProxy = (context: BrowserContext) => {
const injectingPkgPath = process.env.RUBY_NPM_PACKAGE_ROOT;
const injectingPkg = JSON.parse(
readFileSync(path.join(injectingPkgPath, "package.json"), "utf-8"),
);
const cdnPattern = new RegExp(
`cdn.jsdelivr.net/npm/${injectingPkg.name}@.+/dist/(.+)`
);
const cdnPattern =
/cdn.jsdelivr.net\/npm\/@ruby\/.+-wasm-wasi@.+\/dist\/(.+)/;
context.route(cdnPattern, (route) => {
const request = route.request();
console.log(">> [MOCK]", request.method(), request.url());
const relativePath = request.url().match(cdnPattern)[1];
const mockedPath = path.join(
injectingPkgPath,
process.env.RUBY_NPM_PACKAGE_ROOT,
"dist",
relativePath,
);
Expand Down

0 comments on commit 5b51997

Please sign in to comment.