Skip to content

Commit 2c0f150

Browse files
Skip e2e tests with CDN assets when the version is not released yet
1 parent b08c2bc commit 2c0f150

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/npm-packages/ruby-wasm-wasi/test-e2e/examples/examples.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
import { test, expect, Page } from '@playwright/test';
22
import path from "path"
33
import { waitForRubyVM, setupDebugLog, setupProxy } from "../support"
4+
import { readFileSync } from 'fs';
5+
import http from 'http';
6+
import https from 'https';
47

58
test.beforeEach(async ({ context }) => {
69
setupDebugLog(context);
710
if (process.env.RUBY_NPM_PACKAGE_ROOT) {
811
setupProxy(context);
912
} else {
10-
console.info("Testing against CDN deployed files")
13+
console.info("Testing against CDN deployed files");
14+
const packagePath = path.join(__dirname, "..", "..", "package.json")
15+
const packageInfo = JSON.parse(readFileSync(packagePath, "utf-8"))
16+
const version = packageInfo.version
17+
const url = `https://registry.npmjs.org/ruby-head-wasm-wasi/${version}`
18+
const response = await new Promise<http.IncomingMessage>((resolve, reject) => {
19+
https.get(url, resolve).on("error", reject)
20+
})
21+
if (response.statusCode == 404) {
22+
console.log(`ruby-head-wasm-wasi@${version} is not published yet, so skipping CDN tests`);
23+
test.skip();
24+
}
1125
}
1226
})
1327

0 commit comments

Comments
 (0)