Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1147 from Shopify/dependabot/npm_and_yarn/minifla…
Browse files Browse the repository at this point in the history
…re-3.20231218.2

Bump miniflare from 2.14.1 to 3.20231218.2
  • Loading branch information
paulomarg authored Jan 24, 2024
2 parents 8749da3 + 9fbd0f4 commit 81bc22b
Show file tree
Hide file tree
Showing 9 changed files with 493 additions and 129 deletions.
1 change: 1 addition & 0 deletions packages/shopify-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.wrangler
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ function setRestClientRetryTime(time: number) {

/* eslint-disable-next-line import/no-anonymous-default-export */
export default {
async fetch(req: any, _env: any, _ctx: any) {
const apiServerPort: number = parseInt(
(globalThis as any).HTTP_SERVER_PORT || '3000',
10,
);
async fetch(req: any, env: any, _ctx: any) {
const apiServerPort: number = parseInt(env.HTTP_SERVER_PORT || '3000', 10);
const apiServer = `localhost:${apiServerPort}`;
const client = new RestClient({
session: new Session({...session, shop: apiServer}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function allEnvironmentsReady(environments: E2eTestEnvironment[]): boolean {
export async function runEnvironments(
environments: E2eTestEnvironment[],
): Promise<boolean> {
// Give enough time for the servers to start listening
await sleep(2000);

const maxAttempts = 5;

if (allEnvironmentsReady(environments)) return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {spawn} from 'child_process';
import path from 'path';

import '..';

import '../../../runtime/__tests__/all.test';
import {runTests, E2eTestEnvironment} from '../../__e2etests__/e2e-runner.test';

const cfWorkerAppPort = '7777';
// This value must match the one in ./wrangler.toml
const dummyServerPort = '7778';

const workerEnvironment: E2eTestEnvironment = {
Expand All @@ -15,12 +17,14 @@ const workerEnvironment: E2eTestEnvironment = {
process: spawn(
'yarn',
[
'miniflare',
'--global',
`HTTP_SERVER_PORT=${dummyServerPort}`,
'wrangler',
'dev',
'-c',
path.join(__dirname, './wrangler.toml'),
'--port',
`${cfWorkerAppPort}`,
'--modules',
'--inspector-port',
'9249',
'bundle/test-web-api-app.js',
],
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name="test_cf_worker"
compatibility_date="2024-01-22"

send_metrics=false

[vars]
HTTP_SERVER_PORT=7778
12 changes: 8 additions & 4 deletions packages/shopify-api/adapters/web-api/__tests__/web-api.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {spawn} from 'child_process';
import path from 'path';

import '..';

import '../../../runtime/__tests__/all.test';
import {runTests, E2eTestEnvironment} from '../../__e2etests__/e2e-runner.test';

const webApiAppPort = '8888';
// This value must match the one in ./wrangler.toml
const dummyServerPort = '8889';

// We should also try running this on a different environment that implements the Web API for better coverage.
Expand All @@ -16,12 +18,14 @@ const webApiEnvironment: E2eTestEnvironment = {
process: spawn(
'yarn',
[
'miniflare',
'--global',
`HTTP_SERVER_PORT=${dummyServerPort}`,
'wrangler',
'dev',
'-c',
path.join(__dirname, './wrangler.toml'),
'--port',
`${webApiAppPort}`,
'--modules',
'--inspector-port',
'9259',
'bundle/test-web-api-app.js',
],
{
Expand Down
7 changes: 7 additions & 0 deletions packages/shopify-api/adapters/web-api/__tests__/wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name="test_web_api"
compatibility_date="2024-01-22"

send_metrics=false

[vars]
HTTP_SERVER_PORT=8889
5 changes: 3 additions & 2 deletions packages/shopify-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@
"@types/uuid": "^9.0.0",
"express": "^4.17.13",
"jest-environment-miniflare": "^2.12.1",
"miniflare": "^2.6.0",
"miniflare": "^3.20231218.2",
"rollup": "^2.79.1",
"rollup-plugin-swc": "^0.2.1",
"supertest": "^6.1.3"
"supertest": "^6.1.3",
"wrangler": "^3.24.0"
},
"files": [
"**/*.d.ts",
Expand Down
Loading

0 comments on commit 81bc22b

Please sign in to comment.