diff --git a/tests/cypress/support/commands.ts b/tests/cypress/support/commands.ts
index eb62a5f..1d7e028 100644
--- a/tests/cypress/support/commands.ts
+++ b/tests/cypress/support/commands.ts
@@ -1,52 +1,41 @@
-// import '@testing-library/cypress/add-commands'
+///
+import '@testing-library/cypress/add-commands'
+
declare global {
declare namespace Cypress {
interface Chainable {
// 確保你有正確的泛型參數
- fillWith(
- account: string,
- password: string
- ): Chainable>
- LoginWithPassword(
- username: string,
- password: string
- ): Chainable>
- PrepareForGame(): Chainable>
- InitTerminal(): Chainable>
- typeInCommand(command: string): Chainable>
- getQuestInfo(id: string): Chainable>
- checkHint(index: number, total: number): Chainable> // 修改類型
- checkTaskInit(): Chainable>
- waitUntilActive(last: boolean): Chainable> // 注意小寫boolean,並且變量名應該是小寫
- checkPending(): Chainable>
- CompleteStageWithCommands(
- stagename: string
- ): Chainable>
+ LoginWithPassword(username: string, password: string): Chainable
+ PrepareForGame(): Chainable
+ InitTerminal(): Chainable
+ typeInCommand(command: string): Chainable
+ getQuestInfo(id: string): Chainable
+ checkHint(index: number, total: number): Chainable // 修改類型
+ checkTaskInit(): Chainable
+ waitUntilActive(last?: boolean): Chainable // 注意小寫boolean,並且變量名應該是小寫
+ checkPending(): Chainable
+ CompleteStageWithCommands(stagename: string): Chainable
CheckTextElement(
id: string,
chText: string,
enText: string
- ): Chainable>
+ ): Chainable
CheckPlaceholder(
id: string,
chText: string,
enText: string
- ): Chainable>
- CheckTreeElement(element: string): Chainable>
+ ): Chainable
+ CheckTreeElement(element: string): Chainable
}
}
}
-
-Cypress.Commands.add(
- 'LoginWithPassword',
- (username: string, password: string) => {
- cy.clearAllCookies({ domain: null })
- cy.visit('/login')
- cy.get('#username').type(username)
- cy.get('#password').type(password)
- cy.get('#LogInOrSignUp').click()
- }
-)
+Cypress.Commands.add('LoginWithPassword', (username, password) => {
+ cy.clearAllCookies()
+ cy.visit('/login')
+ cy.get('#username').type(username)
+ cy.get('#password').type(password)
+ cy.get('#LogInOrSignUp').click()
+})
Cypress.Commands.add('PrepareForGame', () => {
cy.visit('/')
// make sure the login page is loaded
@@ -110,7 +99,7 @@ Cypress.Commands.add('waitUntilActive', (last = false) => {
return
}
if (value === 'pending' && !last) {
- cy.log(last)
+ cy.log(`${last}`)
cy.typeInCommand('{enter}')
cy.waitUntilActive()
}
diff --git a/tests/tsconfig.json b/tests/tsconfig.json
index 18edb19..1bba77a 100644
--- a/tests/tsconfig.json
+++ b/tests/tsconfig.json
@@ -2,7 +2,8 @@
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
- "types": ["cypress", "node"]
+ "types": ["cypress", "@testing-library/cypress"]
},
- "include": ["**/*.ts"]
+ "include": ["src", "node_modules/cypress", "**/*.ts"],
+ "exclude": ["node_modules/cypress"]
}