use swc for jest
This commit is contained in:
		
							parent
							
								
									2e0075e79c
								
							
						
					
					
						commit
						8e6f1508ed
					
				
					 4 changed files with 540 additions and 438 deletions
				
			
		
							
								
								
									
										15
									
								
								packages/backend/.swcrc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								packages/backend/.swcrc
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | ||||||
|  | { | ||||||
|  |   "$schema": "https://json.schemastore.org/swcrc", | ||||||
|  |   "jsc": { | ||||||
|  |     "parser": { | ||||||
|  |       "syntax": "typescript", | ||||||
|  |       "dynamicImport": true, | ||||||
|  |       "decorators": true | ||||||
|  |     }, | ||||||
|  |     "transform": { | ||||||
|  |       "legacyDecorator": true, | ||||||
|  |       "decoratorMetadata": true | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   "minify": false | ||||||
|  | } | ||||||
|  | @ -61,14 +61,6 @@ module.exports = { | ||||||
| 
 | 
 | ||||||
| 	// A set of global variables that need to be available in all test environments
 | 	// A set of global variables that need to be available in all test environments
 | ||||||
| 	globals: { | 	globals: { | ||||||
| 		"ts-jest": { |  | ||||||
| 			"useESM": true, |  | ||||||
| 			tsconfig: "test/tsconfig.json", |  | ||||||
| 			isolatedModules: true, |  | ||||||
| 			diagnostics: { |  | ||||||
|         exclude: ['**'], |  | ||||||
|       }, |  | ||||||
| 		} |  | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	// 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.
 | 	// 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.
 | ||||||
|  | @ -105,7 +97,7 @@ module.exports = { | ||||||
| 	// notifyMode: "failure-change",
 | 	// notifyMode: "failure-change",
 | ||||||
| 
 | 
 | ||||||
| 	// A preset that is used as a base for Jest's configuration
 | 	// A preset that is used as a base for Jest's configuration
 | ||||||
| 	preset: "ts-jest/presets/js-with-ts-esm", | 	//preset: "ts-jest/presets/js-with-ts-esm",
 | ||||||
| 
 | 
 | ||||||
| 	// Run tests from one or more projects
 | 	// Run tests from one or more projects
 | ||||||
| 	// projects: undefined,
 | 	// projects: undefined,
 | ||||||
|  | @ -185,12 +177,7 @@ module.exports = { | ||||||
| 
 | 
 | ||||||
| 	// A map from regular expressions to paths to transformers
 | 	// A map from regular expressions to paths to transformers
 | ||||||
| 	transform: { | 	transform: { | ||||||
| 		"<regex_match_files>": [ | 		"^.+\\.(t|j)sx?$": ["@swc/jest"], | ||||||
| 			"ts-jest", |  | ||||||
| 			{ |  | ||||||
| 				"useESM": true |  | ||||||
| 			} |  | ||||||
| 		] |  | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
 | 	// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
 | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ | ||||||
| 		"lint": "eslint --quiet \"src/**/*.ts\"", | 		"lint": "eslint --quiet \"src/**/*.ts\"", | ||||||
| 		"jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --detectOpenHandles --runInBand", | 		"jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --detectOpenHandles --runInBand", | ||||||
| 		"jest-and-coverage": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --forceExit --detectOpenHandles --runInBand", | 		"jest-and-coverage": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --forceExit --detectOpenHandles --runInBand", | ||||||
|  | 		"jest-clear": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --clearCache", | ||||||
| 		"test": "npm run jest", | 		"test": "npm run jest", | ||||||
| 		"test-and-coverage": "npm run jest-and-coverage" | 		"test-and-coverage": "npm run jest-and-coverage" | ||||||
| 	}, | 	}, | ||||||
|  | @ -129,6 +130,8 @@ | ||||||
| 	}, | 	}, | ||||||
| 	"devDependencies": { | 	"devDependencies": { | ||||||
| 		"@redocly/openapi-core": "1.0.0-beta.108", | 		"@redocly/openapi-core": "1.0.0-beta.108", | ||||||
|  | 		"@swc/core": "1.3.2", | ||||||
|  | 		"@swc/jest": "0.2.22", | ||||||
| 		"@types/bcryptjs": "2.4.2", | 		"@types/bcryptjs": "2.4.2", | ||||||
| 		"@types/bull": "3.15.9", | 		"@types/bull": "3.15.9", | ||||||
| 		"@types/cbor": "6.0.0", | 		"@types/cbor": "6.0.0", | ||||||
|  | @ -178,8 +181,7 @@ | ||||||
| 		"eslint": "8.23.1", | 		"eslint": "8.23.1", | ||||||
| 		"eslint-plugin-import": "2.26.0", | 		"eslint-plugin-import": "2.26.0", | ||||||
| 		"execa": "6.1.0", | 		"execa": "6.1.0", | ||||||
| 		"jest": "28.0.0", | 		"jest": "29.0.3", | ||||||
| 		"ts-jest": "28.0.8", |  | ||||||
| 		"typescript": "4.8.3" | 		"typescript": "4.8.3" | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue