Skip to content

Commit 62a9464

Browse files
committed
feat(esm): Convert test infrastructure files to ESM
Converted critical test support files: - test/data/graphql/index.js - GraphQL test server - test/data/sandbox/support/bdd_helper.js - BDD test helper - test/data/sandbox/workers-proxy-issue/*.js - Worker test files - test/mock-server/server.js - Mock REST server - test/mock-server/start-mock-server.js - Server startup script These files are required for running the test suite.
1 parent c264148 commit 62a9464

File tree

6 files changed

+28
-17
lines changed

6 files changed

+28
-17
lines changed

test/data/graphql/index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
const path = require('path')
2-
const jsonServer = require('json-server')
3-
const { ApolloServer } = require('@apollo/server')
4-
const { startStandaloneServer } = require('@apollo/server/standalone')
5-
const { resolvers, typeDefs } = require('./schema')
1+
import path from 'path'
2+
import jsonServer from 'json-server'
3+
import { ApolloServer } from '@apollo/server'
4+
import { startStandaloneServer } from '@apollo/server/standalone'
5+
import { resolvers, typeDefs } from './schema.js'
6+
import { fileURLToPath } from 'url'
7+
import { dirname } from 'path'
68

7-
const TestHelper = require('../../support/TestHelper')
9+
const __filename = fileURLToPath(import.meta.url)
10+
const __dirname = dirname(__filename)
11+
12+
import TestHelper from '../../support/TestHelper.js'
813

914
const PORT = TestHelper.graphQLServerPort()
1015

@@ -25,4 +30,4 @@ res.then(({ url }) => {
2530
console.log(`test graphQL server listening on ${url}...`)
2631
})
2732

28-
module.exports = res
33+
export default res

test/data/sandbox/support/bdd_helper.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const assert = require('assert')
2-
const Helper = require('../../../../lib/helper')
1+
import assert from 'assert'
2+
import Helper from '../../../../lib/helper.js'
33

44
class CheckoutHelper extends Helper {
55
constructor(config) {
@@ -58,9 +58,10 @@ class CheckoutHelper extends Helper {
5858

5959
debug(message) {
6060
// Use CodeceptJS output system instead of direct console.log
61-
const output = require('../../../../lib/output')
62-
output.debug(`[Helper] ${message}`)
61+
import('../../../../lib/output.js').then(({ default: output }) => {
62+
output.debug(`[Helper] ${message}`)
63+
})
6364
}
6465
}
6566

66-
module.exports = CheckoutHelper
67+
export default CheckoutHelper

test/data/sandbox/workers-proxy-issue/final_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const assert = require('assert');
1+
import assert from 'assert';
22

33
Feature('Complete validation for issue #5066 fix');
44

test/data/sandbox/workers-proxy-issue/proxy_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const assert = require('assert');
1+
import assert from 'assert';
22

33
Feature('Fix for issue #5066: Unable to inject data between workers because of proxy object');
44

test/mock-server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const express = require('express')
1+
import express from 'express'
22
const app = express()
33
app.use(express.json())
44

test/mock-server/start-mock-server.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
const { spawn } = require('child_process')
2-
const http = require('http')
1+
import { spawn } from 'child_process'
2+
import http from 'http'
3+
import { fileURLToPath } from 'url'
4+
import { dirname } from 'path'
5+
6+
const __filename = fileURLToPath(import.meta.url)
7+
const __dirname = dirname(__filename)
38

49
const PORT = process.env.PORT || 3001
510
const MAX_RETRIES = 20

0 commit comments

Comments
 (0)