docbrown/jest.config.js
Joshua Wehner 6fe9d7d7a6
Allow org admins to add members as co-authors (#20008)
* Basics might be working?

* Stop propagating button clicks in autocomplete pills

* Better blank slate

* Better location to stop propagation

* Remove author_id from org co-authors

* Move UserStore and try testing it

* Remove extraneous comments

* OH... that's what that does!

* Very basic testing

* Re-organize javascripts

* Rename & re-org for testing

* Cleanup

* More tests

* Remove unnecessary nesting

* Coninuing to try to bump coverage

* Include /packs/ in code coverage metric

* Try tweaking jest coverage more?

We probably can't collect coverage from all of packs/* (because coverage is too low) but maybe we can try to opt-in for newer areas as we go?

* Relocate JS tests, for build & coverage

* User ID exception on search, not fetch

* Remove commented-out console.log

---------

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2023-09-15 08:12:41 -04:00

77 lines
2.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Consistent timezone for testing.
// This does not work on windows, see https://github.com/nodejs/node/issues/4230
/* eslint-env node */
process.env.NODE_ENV = 'test';
process.env.TZ = 'UTC';
module.exports = {
setupFilesAfterEnv: ['./testSetup.js'],
collectCoverageFrom: [
'bin/*.js',
'app/javascript/**/*.{js,jsx}',
// This exclusion avoids running coverage on Barrel files, https://twitter.com/housecor/status/981558704708472832
'!app/javascript/**/index.js',
'!app/javascript/packs/**/*.js', // avoids running coverage on webpacker pack files
'app/javascript/packs/dashboards/*.js', // try opting-in for jest coverage?
'!**/__tests__/**',
'!**/__stories__/**',
'!app/javascript/storybook-static/**/*.js',
// We do not need code coverage on files that are prop types
// or eslint configuration files.
'!app/javascript/**/*PropTypes.js',
'!./**/.eslintrc.js',
// Ignore Storybook configuration files
'!app/javascript/.storybook/**/*.{js,jsx}',
],
coverageDirectory: 'coverage/jest',
coverageThreshold: {
global: {
statements: 43,
branches: 45,
functions: 42,
lines: 44,
},
},
moduleNameMapper: {
'\\.(svg|png|css)$': '<rootDir>/empty-module.js',
'^@crayons(.*)$': '<rootDir>/app/javascript/crayons$1',
'^@images(.*)$': '<rootDir>/app/assets/images$1',
'^@utilities(.*)$': '<rootDir>/app/javascript/utilities$1',
'^@components(.*)$': '<rootDir>/app/javascript/shared/components$1',
'^react$': 'preact/compat',
'^react-dom$': 'preact/compat',
},
// The webpack config folder for webpacker is excluded as it has a test.js file that gets
// picked up by jest if this folder is not excluded causing a false negative of a test suite failing.
testPathIgnorePatterns: [
'/node_modules/',
'<rootDir>/config/webpack',
// Allows developers to add utility modules that jest won't run as test suites.
'/__tests__/utilities/',
'<rootDir>/app/javascript/storybook-static',
'<rootDir>/cypress',
],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
testEnvironment: './customJsDomEnvironment.js',
// We occasionally need to allow transpiling of specific node_modules. See https://jestjs.io/docs/configuration#transformignorepatterns-arraystring
transformIgnorePatterns: [
'/node_modules/(?!(preact|react-colorful|i18n-js)/)',
],
reporters: [
'default',
[
'jest-junit',
{
addFileAttribute: 'true',
ancestorSeparator: ' ',
classNameTemplate: '{classname}',
titleTemplate: '{title}',
},
],
],
};