Skip to content
Merged
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: 1 addition & 1 deletion .allowed-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default configureAllowedScripts({
// Needed by esbuild for watching files during development
'node_modules/@parcel/watcher@2.5.1': 'ALLOW',
// Needed by esbuild for watching files during development
'node_modules/cypress@14.5.4': 'ALLOW',
'node_modules/cypress@15.9.0': 'ALLOW',
// Provides native integration, supporting ability to write dtrace probes for bunyan
'node_modules/dtrace-provider@0.8.8': 'ALLOW',
// ESBuild is written in GoLang - this is needed to download prebuilt binaries for the specific platform
Expand Down
14 changes: 14 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import fs from 'fs'
import path from 'node:path'
import webpackPreprocessor from '@cypress/webpack-batteries-included-preprocessor'
import { defineConfig } from 'cypress'
import { resetStubs } from './integration_tests/mockApis/wiremock'
import auth from './integration_tests/mockApis/auth'
Expand All @@ -10,6 +12,17 @@ import supportAdditionalNeedsApi from './integration_tests/mockApis/supportAddit
import personMockDataGenerator from './integration_tests/mockData/personMockDataGenerator'
import curiousApi from './integration_tests/mockApis/curiousApi'

function preprocessorOptions() {
const replacementModulesPath = path.resolve(__dirname, './integration_tests/support/replacementModules')
const options = webpackPreprocessor.defaultOptions
options.typescript = require.resolve('typescript')
options.webpackOptions.resolve.alias = {
bunyan: path.join(replacementModulesPath, 'bunyan.ts'),
'bunyan-format': path.join(replacementModulesPath, 'bunyan-format.ts'),
}
return options
}

export default defineConfig({
chromeWebSecurity: false,
fixturesFolder: 'integration_tests/fixtures',
Expand All @@ -23,6 +36,7 @@ export default defineConfig({
taskTimeout: 60000,
e2e: {
setupNodeEvents(on) {
on('file:preprocessor', webpackPreprocessor(preprocessorOptions()))
on('task', {
log(message) {
// eslint-disable-next-line no-console
Expand Down
9 changes: 9 additions & 0 deletions integration_tests/support/replacementModules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Replacement modules for integration testing

Cypress 15 uses webpack 5 to transform test cases and run them in the browser.
This version of webpack no longer supports polyfilling node standard modules.
While tests here do not actually _use_ node standard modules, they reference modules (via type and mock imports)
that themselves import them – webpack cannot tell that they are unused so transpilation fails.

Files in this folder are the minimal browser-compatible reimplementations of modules that do not transpile.
They are installed in `/cypress.config.ts`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// should return a stream/writable, but can’t really have that in the browser
// however a bunyan logger’s stream can be undefined
export default function bunyanFormat(): undefined {
return undefined
}
6 changes: 6 additions & 0 deletions integration_tests/support/replacementModules/bunyan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// console has many overlapping methods with bunyan loggers
function createLogger() {
return console
}

export default { createLogger }
Loading