Clarify rules for which files are run as Jest integration tests (#33869)

* Add RESERVED_DIR_JEST_INTEGRATION_TESTS to src/dev/constants to aid discoverability of which directory names are reserved.
* Add negation rules so the Jest integration tests script ignores test files inside of __jest__/integration_tests dirs.
This commit is contained in:
CJ Cenizal 2019-03-29 10:34:09 -07:00 committed by GitHub
parent b21f048df9
commit 8d64071d7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 5 deletions

View file

@ -20,3 +20,7 @@
import { dirname } from 'path';
export const REPO_ROOT = dirname(require.resolve('../../package.json'));
// FIles in directories of this name will be treated as Jest integration tests with instances of
// Elasticsearch and the Kibana server.
export const RESERVED_DIR_JEST_INTEGRATION_TESTS = 'integration_tests';

View file

@ -17,6 +17,8 @@
* under the License.
*/
import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../constants';
export default {
rootDir: '../../..',
roots: [
@ -76,7 +78,7 @@ export default {
testPathIgnorePatterns: [
'<rootDir>/packages/kbn-ui-framework/(dist|doc_site|generator-kui)/',
'<rootDir>/packages/kbn-pm/dist/',
'integration_tests/'
`${RESERVED_DIR_JEST_INTEGRATION_TESTS}/`,
],
transform: {
'^.+\\.(js|tsx?)$': '<rootDir>/src/dev/jest/babel_transform.js',

View file

@ -4,16 +4,18 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../../../src/dev/constants';
import config from './config';
export default {
...config,
testMatch: [
'**/integration_tests/**/*.test.js',
'**/integration_tests/**/*.test.ts',
`**/${RESERVED_DIR_JEST_INTEGRATION_TESTS}/**/*.test.{js,ts,tsx}`,
// Tests within `__jest__` directories should be treated as regular unit tests.
`!**/__jest__/${RESERVED_DIR_JEST_INTEGRATION_TESTS}/**/*.test.{js,ts,tsx}`,
],
testPathIgnorePatterns: config.testPathIgnorePatterns.filter(
(pattern) => !pattern.includes('integration_tests')
(pattern) => !pattern.includes(RESERVED_DIR_JEST_INTEGRATION_TESTS)
),
reporters: [
'default',

View file

@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../../../src/dev/constants';
export default {
rootDir: '../../',
roots: [
@ -47,7 +49,7 @@ export default {
testPathIgnorePatterns: [
'<rootDir>/packages/kbn-ui-framework/(dist|doc_site|generator-kui)/',
'<rootDir>/packages/kbn-pm/dist/',
'integration_tests/'
`${RESERVED_DIR_JEST_INTEGRATION_TESTS}/`,
],
transform: {
'^.+\\.(js|tsx?)$': '<rootDir>/../src/dev/jest/babel_transform.js',