Skip to content

Latest commit

 

History

History
69 lines (54 loc) · 1.31 KB

packageJson.md

File metadata and controls

69 lines (54 loc) · 1.31 KB
title
packageJson Config option

The packageJson option specifies the package.json file to use. An inline object may also be specified instead of a file path.

By default, the package.json file at the root of the project will be used. If it cannot be found, an empty project definition will be used instead.

Examples

Path to a packageJson file

The path should be relative to the current working directory where you start Jest from. You can also use <rootDir> in the path to start from the project root dir.

// jest.config.js
module.exports = {
  // [...]
  globals: {
    'ts-jest': {
      packageJson: 'package.json'
    }
  }
};
// OR from a non-trivial path
// jest.config.js
module.exports = {
  // [...]
  globals: {
    'ts-jest': {
      packageJson: '<rootDir>/../../shared/package.json'
    }
  }
};

Inline package metadata

// jest.config.js
module.exports = {
  // [...]
  globals: {
    'ts-jest': {
      packageJson: {
          "name": "my-project",
          "version": "1.0.0",
          "dependencies": {
            // [...]
          }
      }
    }
  }
};