Cypress typescript (#13591)
* convert Cypress tests to TypeScript this work was done by @lunaisnotaboy https://github.com/lunaisnotaboy for their fork https://github.com/cutiekey/cutiekey/pull/7 I just repacked their changes into a minimal set * fix call to `window` in cypress tests this error was spotted thanks to the TypeScript compiler: ``` support/commands.ts:33:12 - error TS2559: Type '(win: any) => void' has no properties in common with type 'Partial<Loggable & Timeoutable>'. 33 cy.window(win => { ~~~~~~~~ Found 1 error in support/commands.ts:33 ``` (again, @lunaisnotaboy did the actual work)
This commit is contained in:
		
							parent
							
								
									115d91812e
								
							
						
					
					
						commit
						d7bb6c88d3
					
				
					 9 changed files with 38 additions and 1 deletions
				
			
		| 
						 | 
					@ -30,7 +30,7 @@ Cypress.Commands.add('visitHome', () => {
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Cypress.Commands.add('resetState', () => {
 | 
					Cypress.Commands.add('resetState', () => {
 | 
				
			||||||
	cy.window(win => {
 | 
						cy.window().then(win => {
 | 
				
			||||||
		win.indexedDB.deleteDatabase('keyval-store');
 | 
							win.indexedDB.deleteDatabase('keyval-store');
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	cy.request('POST', '/api/reset-db', {}).as('reset');
 | 
						cy.request('POST', '/api/reset-db', {}).as('reset');
 | 
				
			||||||
							
								
								
									
										19
									
								
								cypress/support/index.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								cypress/support/index.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					declare global {
 | 
				
			||||||
 | 
						namespace Cypress {
 | 
				
			||||||
 | 
							interface Chainable {
 | 
				
			||||||
 | 
								login(username: string, password: string): Chainable<void>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								registerUser(
 | 
				
			||||||
 | 
									username: string,
 | 
				
			||||||
 | 
									password: string,
 | 
				
			||||||
 | 
									isAdmin?: boolean
 | 
				
			||||||
 | 
								): Chainable<void>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								resetState(): Chainable<void>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								visitHome(): Chainable<void>;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export {}
 | 
				
			||||||
							
								
								
									
										8
									
								
								cypress/tsconfig.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								cypress/tsconfig.json
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"compilerOptions": {
 | 
				
			||||||
 | 
							"lib": ["dom", "es5"],
 | 
				
			||||||
 | 
							"target": "es5",
 | 
				
			||||||
 | 
							"types": ["cypress", "node"]
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"include": ["./**/*.ts"]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -59,6 +59,7 @@
 | 
				
			||||||
		"typescript": "5.3.3"
 | 
							"typescript": "5.3.3"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	"devDependencies": {
 | 
						"devDependencies": {
 | 
				
			||||||
 | 
							"@types/node": "^20.11.28",
 | 
				
			||||||
		"@typescript-eslint/eslint-plugin": "7.1.0",
 | 
							"@typescript-eslint/eslint-plugin": "7.1.0",
 | 
				
			||||||
		"@typescript-eslint/parser": "7.1.0",
 | 
							"@typescript-eslint/parser": "7.1.0",
 | 
				
			||||||
		"cross-env": "7.0.3",
 | 
							"cross-env": "7.0.3",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										9
									
								
								pnpm-lock.yaml
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										9
									
								
								pnpm-lock.yaml
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -44,6 +44,9 @@ importers:
 | 
				
			||||||
        specifier: 4.4.0
 | 
					        specifier: 4.4.0
 | 
				
			||||||
        version: 4.4.0
 | 
					        version: 4.4.0
 | 
				
			||||||
    devDependencies:
 | 
					    devDependencies:
 | 
				
			||||||
 | 
					      '@types/node':
 | 
				
			||||||
 | 
					        specifier: ^20.11.28
 | 
				
			||||||
 | 
					        version: 20.11.28
 | 
				
			||||||
      '@typescript-eslint/eslint-plugin':
 | 
					      '@typescript-eslint/eslint-plugin':
 | 
				
			||||||
        specifier: 7.1.0
 | 
					        specifier: 7.1.0
 | 
				
			||||||
        version: 7.1.0(@typescript-eslint/parser@7.1.0)(eslint@8.57.0)(typescript@5.3.3)
 | 
					        version: 7.1.0(@typescript-eslint/parser@7.1.0)(eslint@8.57.0)(typescript@5.3.3)
 | 
				
			||||||
| 
						 | 
					@ -7650,6 +7653,12 @@ packages:
 | 
				
			||||||
    dependencies:
 | 
					    dependencies:
 | 
				
			||||||
      undici-types: 5.26.5
 | 
					      undici-types: 5.26.5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /@types/node@20.11.28:
 | 
				
			||||||
 | 
					    resolution: {integrity: sha512-M/GPWVS2wLkSkNHVeLkrF2fD5Lx5UC4PxA0uZcKc6QqbIQUJyW1jVjueJYi1z8n0I5PxYrtpnPnWglE+y9A0KA==}
 | 
				
			||||||
 | 
					    dependencies:
 | 
				
			||||||
 | 
					      undici-types: 5.26.5
 | 
				
			||||||
 | 
					    dev: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /@types/node@20.11.5:
 | 
					  /@types/node@20.11.5:
 | 
				
			||||||
    resolution: {integrity: sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==}
 | 
					    resolution: {integrity: sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==}
 | 
				
			||||||
    dependencies:
 | 
					    dependencies:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue