kibana/x-pack/dev-tools/jest/create_jest_config.js
Spencer c6112067fc
[typescript] add typescript support for the server and browser (#19104)
* [typescript] add typescript support for the server and browser

* [ts-jest] upgrade to latest version

* [jest] support test.tsx files

* [jest/ts] modify `ts-jest.tsConfigFile` config based on filePath

* [types] use correct major version of minimatch types

* [jest] add ts support to x-pack jest config

* [ts/projects] fix tsconfig.json not found error message

* [optimizer/ts] use lowercase jsx option

* [tsconfig] remove ui/* alias

* [plguin-helpers] remove mention of `buildSourcePatterns`

* [plugin-helpers] expect typescript to be a devDep

* [dev/build] place transpile tasks next to each other

* [ts/x-pack] add common and server directories to ts project

* [dev/ts/project] use a limited set of globs to find tsconfig files
2018-05-18 10:54:57 -07:00

54 lines
1.5 KiB
JavaScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
export function createJestConfig({
kibanaDirectory,
xPackKibanaDirectory,
}) {
return {
rootDir: xPackKibanaDirectory,
roots: [
"<rootDir>/plugins",
],
moduleFileExtensions: [
"js",
"json",
"ts",
"tsx",
],
moduleNameMapper: {
"^ui/(.*)": `${kibanaDirectory}/src/ui/public/$1`,
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
`${kibanaDirectory}/src/dev/jest/mocks/file_mock.js`,
"\\.(css|less|scss)$": `${kibanaDirectory}/src/dev/jest/mocks/style_mock.js`
},
setupFiles: [
`${kibanaDirectory}/src/dev/jest/setup/babel_polyfill.js`,
`<rootDir>/dev-tools/jest/setup/enzyme.js`
],
testMatch: [
"**/*.test.{js,ts,tsx}"
],
transform: {
"^.+\\.js$": `${kibanaDirectory}/src/dev/jest/babel_transform.js`,
"^.+\\.tsx?$": `${kibanaDirectory}/src/dev/jest/ts_transform.js`,
},
transformIgnorePatterns: [
"[/\\\\]node_modules[/\\\\].+\\.js$"
],
snapshotSerializers: [
`${kibanaDirectory}/node_modules/enzyme-to-json/serializer`
],
"reporters": [
"default",
[`${kibanaDirectory}/src/dev/jest/junit_reporter.js`, {
reportName: 'X-Pack Jest Tests',
rootDirectory: xPackKibanaDirectory,
}]
]
};
}