Jest Platform
You can cherry pick specific features of Jest and use them as standalone packages. Here's a list of the available packages:
jest-changed-files
Tool for identifying modified files in a git/hg repository. Exports two functions:
getChangedFilesForRoots
returns a promise that resolves to an object with the changed files and repos.findRepos
returns a promise that resolves to a set of repositories contained in the specified path.
Example
const {getChangedFilesForRoots} = require('jest-changed-files');
// print the set of modified files since last commit in the current repo
getChangedFilesForRoots(['./'], {
lastCommit: true,
}).then(result => console.log(result.changedFiles));
You can read more about jest-changed-files
in the readme file.
jest-diff
Tool for visualizing changes in data. Exports a function that compares two values of any type and returns a "pretty-printed" string illustrating the difference between the two arguments.
Example
const {diff} = require('jest-diff');
const a = {a: {b: {c: 5}}};
const b = {a: {b: {c: 6}}};
const result = diff(a, b);
// print diff
console.log(result);
jest-docblock
Tool for extracting and parsing the comments at the top of a JavaScript file. Exports various functions to manipulate the data inside the comment block.
Example
const {parseWithComments} = require('jest-docblock');
const code = `
/**
* This is a sample
*
* @flow
*/
console.log('Hello World!');
`;
const parsed = parseWithComments(code);
// prints an object with two attributes: comments and pragmas.
console.log(parsed);
You can read more about jest-docblock
in the readme file.
jest-get-type
Module that identifies the primitive type of any JavaScript value. Exports a function that returns a string with the type of the value passed as argument.
Example
const {getType} = require('jest-get-type');
const array = [1, 2, 3];
const nullValue = null;
const undefinedValue = undefined;
// prints 'array'
console.log(getType(array));
// prints 'null'
console.log(getType(nullValue));
// prints 'undefined'
console.log(getType(undefinedValue));