feat: jest fails if something gets logged to console
							parent
							
								
									7e28c861a8
								
							
						
					
					
						commit
						fdef5575f8
					
				|  | @ -1,12 +1,30 @@ | ||||||
| module.exports = { | module.exports = { | ||||||
|  |   // Automatically clear mock calls and instances between every test
 | ||||||
|   clearMocks: true, |   clearMocks: true, | ||||||
|  | 
 | ||||||
|  |   // An array of file extensions your modules use
 | ||||||
|   moduleFileExtensions: ['js', 'ts'], |   moduleFileExtensions: ['js', 'ts'], | ||||||
|  | 
 | ||||||
|  |   // The test environment that will be used for testing
 | ||||||
|   testEnvironment: 'node', |   testEnvironment: 'node', | ||||||
|  | 
 | ||||||
|  |   // The glob patterns Jest uses to detect test files
 | ||||||
|   testMatch: ['**/*.test.ts'], |   testMatch: ['**/*.test.ts'], | ||||||
|  | 
 | ||||||
|  |   // This option allows use of a custom test runner
 | ||||||
|   testRunner: 'jest-circus/runner', |   testRunner: 'jest-circus/runner', | ||||||
|  | 
 | ||||||
|  |   // A map with regular expressions for transformers to paths
 | ||||||
|   transform: { |   transform: { | ||||||
|     '^.+\\.ts$': 'ts-jest', |     '^.+\\.ts$': 'ts-jest', | ||||||
|   }, |   }, | ||||||
|  | 
 | ||||||
|  |   // Indicates whether each individual test should be reported during the run
 | ||||||
|   verbose: true, |   verbose: true, | ||||||
|  | 
 | ||||||
|  |   // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
 | ||||||
|   modulePathIgnorePatterns: ['<rootDir>/lib/', '<rootDir>/dist/'], |   modulePathIgnorePatterns: ['<rootDir>/lib/', '<rootDir>/dist/'], | ||||||
|  | 
 | ||||||
|  |   // A list of paths to modules that run some code to configure or set up the testing framework before each test
 | ||||||
|  |   setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -0,0 +1,9 @@ | ||||||
|  | import failOnConsole from 'jest-fail-on-console'; | ||||||
|  | 
 | ||||||
|  | // Fail when console logs something inside a test - use spyOn instead
 | ||||||
|  | failOnConsole({ | ||||||
|  |   shouldFailOnWarn: true, | ||||||
|  |   shouldFailOnError: true, | ||||||
|  |   shouldFailOnLog: true, | ||||||
|  |   shouldFailOnAssert: true, | ||||||
|  | }); | ||||||
|  | @ -55,6 +55,7 @@ | ||||||
|     "eslint-plugin-unicorn": "28.0.2", |     "eslint-plugin-unicorn": "28.0.2", | ||||||
|     "jest": "^27.5.1", |     "jest": "^27.5.1", | ||||||
|     "jest-circus": "^27.5.1", |     "jest-circus": "^27.5.1", | ||||||
|  |     "jest-fail-on-console": "^2.3.0", | ||||||
|     "js-yaml": "^4.1.0", |     "js-yaml": "^4.1.0", | ||||||
|     "prettier": "^2.5.1", |     "prettier": "^2.5.1", | ||||||
|     "ts-jest": "^27.1.3", |     "ts-jest": "^27.1.3", | ||||||
|  |  | ||||||
|  | @ -7,12 +7,14 @@ export class GitRepoReader { | ||||||
|   static GetSha() { |   static GetSha() { | ||||||
|     return ''; |     return ''; | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|   public static async GetRemote() { |   public static async GetRemote() { | ||||||
|     return (await CloudRunnerSystem.Run(`git remote -v`)) |     return (await CloudRunnerSystem.Run(`git remote -v`)) | ||||||
|       .split(' ')[1] |       .split(' ')[1] | ||||||
|       .split('https://github.com/')[1] |       .split('https://github.com/')[1] | ||||||
|       .split('.git')[0]; |       .split('.git')[0]; | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|   public static async GetBranch() { |   public static async GetBranch() { | ||||||
|     assert(fs.existsSync(`.git`)); |     assert(fs.existsSync(`.git`)); | ||||||
|     return (await System.run(`git branch`, [], {}, false)).split('*')[1].split(`\n`)[0].replace(/ /g, ``); |     return (await System.run(`git branch`, [], {}, false)).split('*')[1].split(`\n`)[0].replace(/ /g, ``); | ||||||
|  |  | ||||||
|  | @ -2,8 +2,11 @@ import { GithubCliReader } from './github-cli'; | ||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| 
 | 
 | ||||||
| describe(`github cli`, () => { | describe(`github cli`, () => { | ||||||
|   it(`returns`, async () => { |   // Todo - We can not assume that everyone has the GitHub cli installed locally.
 | ||||||
|  |   it.skip(`returns`, async () => { | ||||||
|     const token = await GithubCliReader.GetGitHubAuthToken(); |     const token = await GithubCliReader.GetGitHubAuthToken(); | ||||||
|  | 
 | ||||||
|  |     // Todo - use expect(result).toStrictEqual(something)
 | ||||||
|     core.info(token); |     core.info(token); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
							
								
								
									
										15
									
								
								yarn.lock
								
								
								
								
							
							
						
						
									
										15
									
								
								yarn.lock
								
								
								
								
							|  | @ -1853,6 +1853,14 @@ chalk@^4.0.0: | ||||||
|     ansi-styles "^4.1.0" |     ansi-styles "^4.1.0" | ||||||
|     supports-color "^7.1.0" |     supports-color "^7.1.0" | ||||||
| 
 | 
 | ||||||
|  | chalk@^4.1.0: | ||||||
|  |   version "4.1.2" | ||||||
|  |   resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" | ||||||
|  |   integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== | ||||||
|  |   dependencies: | ||||||
|  |     ansi-styles "^4.1.0" | ||||||
|  |     supports-color "^7.1.0" | ||||||
|  | 
 | ||||||
| char-regex@^1.0.2: | char-regex@^1.0.2: | ||||||
|   version "1.0.2" |   version "1.0.2" | ||||||
|   resolved "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz" |   resolved "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz" | ||||||
|  | @ -3360,6 +3368,13 @@ jest-environment-node@^27.5.1: | ||||||
|     jest-mock "^27.5.1" |     jest-mock "^27.5.1" | ||||||
|     jest-util "^27.5.1" |     jest-util "^27.5.1" | ||||||
| 
 | 
 | ||||||
|  | jest-fail-on-console@^2.3.0: | ||||||
|  |   version "2.3.0" | ||||||
|  |   resolved "https://registry.yarnpkg.com/jest-fail-on-console/-/jest-fail-on-console-2.3.0.tgz#bf22af0e535512ec7e220223279e3fb7ae621b8b" | ||||||
|  |   integrity sha512-RwTq79+v5OccU59VmhoTvsCyTQ11YeOtLL6xLtkks/H7afLay6gASk6a4qMlyLlpM36t0rPW+DQsJ4ZNcCS2ug== | ||||||
|  |   dependencies: | ||||||
|  |     chalk "^4.1.0" | ||||||
|  | 
 | ||||||
| jest-get-type@^27.5.1: | jest-get-type@^27.5.1: | ||||||
|   version "27.5.1" |   version "27.5.1" | ||||||
|   resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1" |   resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue