Skip to content

Commit

Permalink
fix: Fix issues with dynamic imports when running jest
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Dec 13, 2023
1 parent ae638ad commit 1748b5f
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 7 deletions.
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# We will alow consumers to specify the node version in case we want
# to test under different versions (since we cannot control users environment)
#
# There is nothing wrong with 18.16.0 except for a tiny issue
# in docker compose - a segmentation fault that happens
# when we try to use a dynamic import in our tests (affecting both mocha & jest)
#
# The issue has been described here https://github.com/jestjs/jest/issues/12286
# And relates to this node issue here https://github.com/nodejs/node/issues/43205
#
# This issue does not affect users, it's only related to the test runner
# so the code will still work on node 18.16.0
ARG NODE_VERSION=20.10.0

# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
Expand All @@ -7,7 +21,7 @@
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
FROM node:18.16.0 as base
FROM node:$NODE_VERSION as base

ENV YARN_CACHE_FOLDER=/tmp/yarn_cache

Expand Down
6 changes: 0 additions & 6 deletions docker-compose.templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,3 @@ services:
interval: 2s
retries: 20
test: ["CMD", "curl", "-f", "http://0.0.0.0:8545/"]

# Service that can build this package
tests:
extends:
service: project
working_dir: /app/packages/ua-utils-evm-hardhat-test
1 change: 1 addition & 0 deletions packages/io-utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/omnicounter-utils-evm/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/omnicounter-utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/protocol-utils-evm/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/protocol-utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/toolbox-hardhat/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
testTimeout: 15000,
moduleNameMapper: {
Expand Down
1 change: 1 addition & 0 deletions packages/ua-utils-evm-hardhat-test/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
testTimeout: 15000,
moduleNameMapper: {
Expand Down
1 change: 1 addition & 0 deletions packages/ua-utils-evm-hardhat/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/ua-utils-evm/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/ua-utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/utils-evm-hardhat/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/utils-evm-test/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
testTimeout: 15000,
moduleNameMapper: {
Expand Down
1 change: 1 addition & 0 deletions packages/utils-evm/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
Expand Down

0 comments on commit 1748b5f

Please sign in to comment.