Advertisement
Guest User

Jest Config

a guest
Feb 16th, 2023
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 6.96 KB | Source Code | 0 0
  1. /*
  2.  * For a detailed explanation regarding each configuration property, visit:
  3.  * https://jestjs.io/docs/configuration
  4.  */
  5. const jquery = require('jquery');
  6. const moment = require('moment');
  7.  
  8. module.exports = {
  9.   // All imported modules in your tests should be mocked automatically
  10.   // automock: false,
  11.  
  12.   // Stop running tests after `n` failures
  13.   // bail: 0,
  14.  
  15.   // The directory where Jest should store its cached dependency information
  16.   // cacheDirectory: "/tmp/jest_rs",
  17.  
  18.   // Automatically clear mock calls, instances, contexts and results before every test
  19.   clearMocks: true,
  20.  
  21.   // Indicates whether the coverage information should be collected while executing the test
  22.   // collectCoverage: true,
  23.  
  24.   // An array of glob patterns indicating a set of files for which coverage information should be collected
  25.   // collectCoverageFrom: undefined,
  26.  
  27.   // The directory where Jest should output its coverage files
  28.   // coverageDirectory: 'coverage',
  29.  
  30.   // An array of regexp pattern strings used to skip coverage collection
  31.   // coveragePathIgnorePatterns: [
  32.   //   "/node_modules/"
  33.   // ],
  34.  
  35.   // Indicates which provider should be used to instrument code for coverage
  36.   // coverageProvider: "babel",
  37.  
  38.   // A list of reporter names that Jest uses when writing coverage reports
  39.   // coverageReporters: [
  40.   //   "json",
  41.   //   "text",
  42.   //   "lcov",
  43.   //   "clover"
  44.   // ],
  45.  
  46.   // An object that configures minimum threshold enforcement for coverage results
  47.   // coverageThreshold: undefined,
  48.  
  49.   // A path to a custom dependency extractor
  50.   // dependencyExtractor: undefined,
  51.  
  52.   // Make calling deprecated APIs throw helpful error messages
  53.   // errorOnDeprecated: false,
  54.  
  55.   // The default configuration for fake timers
  56.   // fakeTimers: {
  57.   //   "enableGlobally": false
  58.   // },
  59.  
  60.   // Force coverage collection from ignored files using an array of glob patterns
  61.   // forceCoverageMatch: [],
  62.  
  63.   // A path to a module which exports an async function that is triggered once before all test suites
  64.   // globalSetup: undefined,
  65.  
  66.   // A path to a module which exports an async function that is triggered once after all test suites
  67.   // globalTeardown: undefined,
  68.  
  69.   // A set of global variables that need to be available in all test environments
  70.   globals: {
  71.     moment: moment,
  72.     $: jquery,
  73.     jQuery: jquery
  74.   },
  75.  
  76.   // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
  77.   // maxWorkers: "50%",
  78.  
  79.   // An array of directory names to be searched recursively up from the requiring module's location
  80.   moduleDirectories: ['node_modules', '<rootDir>/src/tests/jest'],
  81.  
  82.   // An array of file extensions your modules use
  83.   // moduleFileExtensions: [
  84.   //   "js",
  85.   //   "mjs",
  86.   //   "cjs",
  87.   //   "jsx",
  88.   //   "ts",
  89.   //   "tsx",
  90.   //   "json",
  91.   //   "node"
  92.   // ],
  93.  
  94.   // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
  95.   moduleNameMapper: {
  96.     // highcharts: require.resolve('highcharts'),
  97.     '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
  98.       '<rootDir>/src/tests/jest/fileMock.js',
  99.     '\\.(scss|css)$': '<rootDir>/src/tests/jest/styleMock.js'
  100.   },
  101.  
  102.   // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
  103.   // modulePathIgnorePatterns: [],
  104.  
  105.   // Activates notifications for test results
  106.   // notify: false,
  107.  
  108.   // An enum that specifies notification mode. Requires { notify: true }
  109.   // notifyMode: "failure-change",
  110.  
  111.   // A preset that is used as a base for Jest's configuration
  112.   // preset: undefined,
  113.  
  114.   // Run tests from one or more projects
  115.   // projects: undefined,
  116.  
  117.   // Use this configuration option to add custom reporters to Jest
  118.   // reporters: undefined,
  119.  
  120.   // Automatically reset mock state before every test
  121.   // resetMocks: false,
  122.  
  123.   // Reset the module registry before running each individual test
  124.   // resetModules: false,
  125.  
  126.   // A path to a custom resolver
  127.   // resolver: undefined,
  128.  
  129.   // Automatically restore mock state and implementation before every test
  130.   // restoreMocks: false,
  131.  
  132.   // The root directory that Jest should scan for tests and modules within
  133.   // rootDir: undefined,
  134.  
  135.   // A list of paths to directories that Jest should use to search for files in
  136.   roots: ['<rootDir>/src'],
  137.  
  138.   // Allows you to use a custom runner instead of Jest's default test runner
  139.   // runner: "jest-runner",
  140.  
  141.   // The paths to modules that run some code to configure or set up the testing environment before each test
  142.   setupFiles: ['./webpack.config.js', './webpack.config.test.js'],
  143.  
  144.   // A list of paths to modules that run some code to configure or set up the testing framework before each test
  145.   // setupFilesAfterEnv: [],
  146.  
  147.   // The number of seconds after which a test is considered as slow and reported as such in the results.
  148.   // slowTestThreshold: 5,
  149.  
  150.   // A list of paths to snapshot serializer modules Jest should use for snapshot testing
  151.   // snapshotSerializers: [],
  152.  
  153.   // The test environment that will be used for testing
  154.   // testEnvironment: "jest-environment-node",
  155.   testEnvironment: 'jsdom',
  156.  
  157.   // Options that will be passed to the testEnvironment
  158.   // testEnvironmentOptions: {},
  159.  
  160.   // Adds a location field to test results
  161.   // testLocationInResults: false,
  162.  
  163.   // The glob patterns Jest uses to detect test files
  164.  
  165.   testMatch: ['**/?(*.)+(spec).js?(x)'],
  166.  
  167.   // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
  168.   // testPathIgnorePatterns: [
  169.   //   "/node_modules/"
  170.   // ],
  171.  
  172.   // The regexp pattern or array of patterns that Jest uses to detect test files
  173.   // testRegex: [],
  174.  
  175.   // This option allows the use of a custom results processor
  176.   // testResultsProcessor: undefined,
  177.  
  178.   // This option allows use of a custom test runner
  179.   // testRunner: "jest-circus/runner",
  180.  
  181.   // A map from regular expressions to paths to transformers
  182.   // transform: {
  183.   //   '^.+\\.js$': 'babel-jest'
  184.   // },
  185.  
  186.   // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
  187.   // transformIgnorePatterns: [
  188.   //   '/node_modules/',
  189.   //   '\\.pnp\\.[^\\/]+$'
  190.   // ],
  191.   transformIgnorePatterns: ['node_modules/(?!(highcharts)/)'],
  192.  
  193.   // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
  194.   // unmockedModulePathPatterns: undefined,
  195.  
  196.   // Indicates whether each individual test should be reported during the run
  197.   verbose: true
  198.  
  199.   // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
  200.   // watchPathIgnorePatterns: [],
  201.  
  202.   // Whether to use watchman for file crawling
  203.   // watchman: true,
  204. };
  205.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement