Skip to content

Commit

Permalink
ci: no fetch only for node18 and nonminified browser code for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau committed Oct 3, 2022
1 parent 68b31f7 commit bff8e82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 39 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,22 @@ jobs:
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci

# Start Bee Factory environment
- name: Start Bee Factory environment
if: matrix.node-version != '18.x'
run: npm run bee -- --verbose --detach

# Start Bee Factory environment for Node 18
- name: Start Bee Factory environment for Node 18
- name: Run unit and integration tests for node
if: matrix.node-version != '18.x'
run: npm run test:node -- --detectOpenHandles

- name: Node 18 specific Bee Factory and tests run
if: matrix.node-version == '18.x'
env:
NODE_OPTIONS: '--no-experimental-fetch'
run: npm run bee -- --verbose --detach
run: |
npm run bee -- --verbose --detach
npm run test:node -- --detectOpenHandles
- name: Run unit and integration tests for node
run: npm run test:node -- --detectOpenHandles
- name: Debug workflow if failed
if: failure()
Expand Down
30 changes: 0 additions & 30 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,6 @@
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/en/configuration.html
*/
import Glob from 'glob'
import * as Path from 'path'
import { dirname } from 'path'
import { fileURLToPath } from 'url'

const __dirname = dirname(fileURLToPath(import.meta.url))

export async function getBrowserPathMapping () {
const browserSourceFiles = await new Promise((resolve, reject) => {
Glob.glob('src/**/*.browser.ts', (err, browserSourceCodes) => {
if (err) reject(err)
browserSourceCodes = browserSourceCodes.map(match => Path.resolve(__dirname, match))
const codePathMapping = {}
browserSourceCodes.map(browserFullPath => {
const filePathArray = browserFullPath.split('.')
filePathArray.pop()
filePathArray.pop() //remove 'browser.ts' from '**/*.browser.ts'
const nodeFullPath = filePathArray.join('.')
const aliasNodeReference = `/${nodeFullPath.split('/').pop()}$` //keep the last bit of node file referencing e.g. '/file-source$'

codePathMapping[aliasNodeReference] = browserFullPath
})

resolve(codePathMapping)
})
})

return browserSourceFiles
}

export default async () => {
return {
Expand Down Expand Up @@ -68,7 +39,6 @@ export default async () => {
{
displayName: 'dom:integration',
testRegex: 'test/integration/.*\\.browser\\.spec\\.ts',
moduleNameMapper: await getBrowserPathMapping(),
preset: 'jest-puppeteer',
extensionsToTreatAsEsm: ['.ts'],
transform: {
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@
"build:node": "tsc && babel --no-babelrc --plugins \"babel-plugin-add-import-extension\" --out-dir dist/src/ dist/src/",
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types",
"build:browser": "esbuild src/index.ts --minify --bundle --format=esm --sourcemap --platform=browser --outfile=dist/index.browser.js",
"build:browser:nonminify": "esbuild src/index.ts --bundle --format=esm --sourcemap --platform=browser --outfile=dist/index.browser.js",
"mock-ci": "npm run lint:check && npm run check:types && npm run test",
"test": "npm run build:browser && cross-env JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs NODE_OPTIONS='--experimental-vm-modules --no-experimental-fetch' jest --no-cache --verbose --selectProjects=node:unit node:integration dom:integration",
"test:integration:browser": "npm run build:browser && cross-env JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs NODE_OPTIONS='--experimental-vm-modules --no-experimental-fetch' jest --no-cache --verbose --selectProjects=dom:integration",
"test": "npm run build:browser:nonminify && cross-env JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs NODE_OPTIONS='--experimental-vm-modules' jest --no-cache --verbose --selectProjects=node:unit node:integration dom:integration",
"test:integration:browser": "npm run build:browser:nonminify && cross-env JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs NODE_OPTIONS='--experimental-vm-modules --no-experimental-fetch' jest --no-cache --verbose --selectProjects=dom:integration",
"test:integration:node": "cross-env NODE_OPTIONS='--experimental-vm-modules --no-experimental-fetch' jest --no-cache --verbose --selectProjects=node:integration",
"test:integration": "npm run build:browser && cross-env JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs NODE_OPTIONS='--experimental-vm-modules --no-experimental-fetch' jest --no-cache --verbose --selectProjects=node:integration dom:integration",
"test:integration": "npm run build:browser:nonminify && cross-env JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs NODE_OPTIONS='--experimental-vm-modules --no-experimental-fetch' jest --no-cache --verbose --selectProjects=node:integration dom:integration",
"test:unit": "cross-env NODE_OPTIONS='--experimental-vm-modules --no-experimental-fetch' jest --no-cache --verbose --selectProjects=node:unit",
"test:node": "cross-env NODE_OPTIONS='--experimental-vm-modules --no-experimental-fetch' jest --no-cache --verbose --selectProjects=node:unit node:integration",
"test:browser": "npm run test:integration:browser",
Expand Down

0 comments on commit bff8e82

Please sign in to comment.