Options
All
  • Public
  • Public/Protected
  • All
Menu

Monorepo Helpers - v1.0.0

Here you can find some helpers to make you Jest configuration easier.

Index

Functions

Const jestPackageConfig

  • Generate a Jest configuration object for an specific package.

    Quick use

    ES6

    // ./packages/packageA/jest.config.ts
    import { jestPackageConfig } from "@elmijo/monorepo-helper"
    export default jestPackageConfig({ projectDir: __dirname })

    CommonJS

    // ./packages/packageA/jest.config.ts
    const { jestPackageConfig } = require("@elmijo/monorepo-helper")
    module.exports = jestPackageConfig({ projectDir: __dirname })

    Custom use

    ES6

    // ./packages/packageA/jest.config.ts
    import { Config } from "@jest/types"
    import { jestPackageConfig } from "@elmijo/monorepo-helper"
    export default {
    ...jestPackageConfig({ projectDir: __dirname }),
    verbode: true
    } as Config.InitialOptions

    CommonJS

    // ./packages/packageA/jest.config.ts
    const { jestPackageConfig } = require("@elmijo/monorepo-helper")
    module.exports = {
    ...jestPackageConfig({ projectDir: __dirname })
    verbose: true
    }

    Parameters

    • projectOpts: PackageInfoOptions

      configuration options to generate a Jest configuration.

    • tsConfigName: string = "tsconfig"

      The name of the tsconfig file.

    Returns JestConfig

    A Jest configuration object.

Const jestRootConfig

  • jestRootConfig(packageRepos: string[], tsConfigName?: string): JestConfig
  • Generate a root Jest configuration object for monorepos.

    Quick use

    ES6

    // jest.config.ts
    import { jestRootConfig } from "@elmijo/monorepo-helper"
    export default jestRootConfig(["./packages"])

    CommonJS

    // jest.config.ts
    const { jestRootConfig } = require("@elmijo/monorepo-helper")
    module.exports = jestRootConfig(["./packages"])

    Custom use

    ES6

    // jest.config.ts
    import { Config } from "@jest/types"
    import { jestRootConfig } from "@elmijo/monorepo-helper"
    export default {
    ...jestRootConfig(["./packages"]),
    verbose: true
    } as Config.InitialOptions

    CommonJS

    // jest.config.ts
    const { jestRootConfig } = require("@elmijo/monorepo-helper");
    module.exports = {
    ...jestRootConfig(["./packages"]),
    verbose: true
    };

    Parameters

    • packageRepos: string[]

      List of package repositories

    • tsConfigName: string = "tsconfig"

      The name of the Typescript configuration

    Returns JestConfig

    Return a Jest configuration object.

Generated using TypeDoc