| 
									
										
										
										
											2023-03-22 11:21:33 +01:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const path = require('path'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const moduleNameMapper = { | 
					
						
							| 
									
										
										
										
											2023-04-19 15:10:50 +01:00
										 |  |  |   '.*\\.(css|less|styl|scss|sass)$': '@strapi/admin-test-utils/file-mock', | 
					
						
							| 
									
										
										
										
											2023-03-22 11:21:33 +01:00
										 |  |  |   '.*\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$': | 
					
						
							| 
									
										
										
										
											2023-04-19 15:10:50 +01:00
										 |  |  |     '@strapi/admin-test-utils/file-mock', | 
					
						
							| 
									
										
										
										
											2023-07-11 11:03:35 +01:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * we're mapping the following packages to the monorepos node_modules | 
					
						
							|  |  |  |    * so if you link a package e.g. `design-system` the correct dependencies | 
					
						
							|  |  |  |    * are used and the tests run correctly. | 
					
						
							|  |  |  |    **/ | 
					
						
							| 
									
										
										
										
											2023-07-10 14:25:25 +01:00
										 |  |  |   '^react$': path.join(__dirname, 'node_modules/react'), | 
					
						
							|  |  |  |   '^react-dom$': path.join(__dirname, 'node_modules/react-dom'), | 
					
						
							|  |  |  |   '^react-router-dom$': path.join(__dirname, 'node_modules/react-router-dom'), | 
					
						
							|  |  |  |   '^styled-components$': path.join(__dirname, 'node_modules/styled-components'), | 
					
						
							| 
									
										
										
										
											2023-03-22 11:21:33 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = { | 
					
						
							|  |  |  |   rootDir: __dirname, | 
					
						
							|  |  |  |   moduleNameMapper, | 
					
						
							| 
									
										
										
										
											2023-05-23 21:17:13 +02:00
										 |  |  |   /* Tells jest to ignore duplicated manual mock files, such as index.js */ | 
					
						
							|  |  |  |   modulePathIgnorePatterns: ['.*__mocks__.*'], | 
					
						
							| 
									
										
										
										
											2023-07-27 13:05:53 +01:00
										 |  |  |   testPathIgnorePatterns: ['node_modules/', '__tests__'], | 
					
						
							| 
									
										
										
										
											2023-04-19 15:10:50 +01:00
										 |  |  |   globalSetup: '@strapi/admin-test-utils/global-setup', | 
					
						
							|  |  |  |   setupFiles: ['@strapi/admin-test-utils/environment'], | 
					
						
							|  |  |  |   setupFilesAfterEnv: ['@strapi/admin-test-utils/after-env'], | 
					
						
							| 
									
										
										
										
											2023-03-22 11:21:33 +01:00
										 |  |  |   testEnvironment: 'jsdom', | 
					
						
							|  |  |  |   transform: { | 
					
						
							| 
									
										
										
										
											2023-08-07 10:44:05 +01:00
										 |  |  |     '^.+\\.js(x)?$': [ | 
					
						
							| 
									
										
										
										
											2023-03-22 11:21:33 +01:00
										 |  |  |       '@swc/jest', | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         env: { | 
					
						
							|  |  |  |           coreJs: '3.28.0', | 
					
						
							|  |  |  |           mode: 'usage', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         jsc: { | 
					
						
							|  |  |  |           parser: { | 
					
						
							|  |  |  |             jsx: true, | 
					
						
							|  |  |  |             dynamicImport: true, | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           // this should match the minimum supported node.js version
 | 
					
						
							|  |  |  |           target: 'es2020', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ], | 
					
						
							| 
									
										
										
										
											2023-08-07 10:44:05 +01:00
										 |  |  |     '\\.ts$': [ | 
					
						
							|  |  |  |       '@swc/jest', | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         jsc: { | 
					
						
							|  |  |  |           parser: { | 
					
						
							|  |  |  |             syntax: 'typescript', | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |     '\\.tsx$': [ | 
					
						
							|  |  |  |       '@swc/jest', | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         jsc: { | 
					
						
							|  |  |  |           parser: { | 
					
						
							|  |  |  |             syntax: 'typescript', | 
					
						
							|  |  |  |             tsx: true, | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           transform: { | 
					
						
							|  |  |  |             react: { | 
					
						
							|  |  |  |               runtime: 'automatic', | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ], | 
					
						
							| 
									
										
										
										
											2023-03-22 11:21:33 +01:00
										 |  |  |     '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': | 
					
						
							|  |  |  |       path.join(__dirname, 'fileTransformer.js'), | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   transformIgnorePatterns: [ | 
					
						
							|  |  |  |     'node_modules/(?!(react-dnd|dnd-core|react-dnd-html5-backend|@strapi/design-system|@strapi/icons|fractional-indexing)/)', | 
					
						
							|  |  |  |   ], | 
					
						
							| 
									
										
										
										
											2023-04-26 13:09:24 +02:00
										 |  |  |   testMatch: ['**/tests/**/?(*.)+(spec|test).[jt]s?(x)'], | 
					
						
							| 
									
										
										
										
											2023-03-22 11:21:33 +01:00
										 |  |  |   testEnvironmentOptions: { | 
					
						
							|  |  |  |     url: 'http://localhost:1337/admin', | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   // Use `jest-watch-typeahead` version 0.6.5. Newest version 1.0.0 does not support jest@26
 | 
					
						
							|  |  |  |   // Reference: https://github.com/jest-community/jest-watch-typeahead/releases/tag/v1.0.0
 | 
					
						
							|  |  |  |   watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'], | 
					
						
							|  |  |  | }; |