Skip to content

How can I use jest-dynamodb in a nx managed monorepo? #217

Open
@zhaoyi0113

Description

@zhaoyi0113

I have a monorepo managed by nx. Each package in this repo references the jest config file from repo root directory. I need to use @shelf/jest-dynamodb to support running dynamodb local for test cases. (https://github.com/shelfio/jest-dynamodb)

One of the package is under packages/is-even/jest.config.js like below:

import path from 'path';

/* eslint-disable */
process.env.JEST_DYNAMODB_CONFIG = path.resolve(__dirname, './jest-dynamodb-config');

console.log('JEST_DYNAMODB_CONFIG:', process.env.JEST_DYNAMODB_CONFIG);

export default {
  displayName: 'is-even',
  preset: '../../jest.preset.js',
};

the root level jest.preset.js is:

module.exports = {
  preset: '@shelf/jest-dynamodb',
  testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
  resolver: '@nx/jest/plugins/resolver',
  moduleFileExtensions: ['ts', 'js'],
  transform: { '^.+\\.(ts|js|html)$': ['ts-jest', [Object]] },
  testEnvironment: 'node',
  testEnvironmentOptions: { customExportConditions: ['node', 'require', 'default'] },
  testTimeout: 5000,

when running the test case, the local dynamodb instance is not launched. Is there a way to make it work with monorepo?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions