Skip to content

Commit

Permalink
Merge pull request #1 from mark0203/Cypress_Typescript_empty_framework
Browse files Browse the repository at this point in the history
Adjust framework to use Typescript
  • Loading branch information
mark0203 authored Aug 8, 2023
2 parents 85d3a09 + ac65281 commit a4d85b7
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
22 changes: 22 additions & 0 deletions CYPRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ Cypress is a test automation tool that make testing fairly easy. Here is what yo
* Convert all .js files to .ts files
* Go over the best [practices page](https://docs.cypress.io/guides/references/best-practices)

# Typescript
Javascript is al fine, but what about using typescript? No problem, follow the steps below to install and configure Typescript.
Just remember to use `pnpm` instead of `npm` for every installation part in the documentation.
* [Cypress.io docs - Typescript](https://docs.cypress.io/guides/tooling/typescript-support)
* `pnpm install --save-dev typescript`
* Inside the `cypress` folder, add a file `tsconfig.json` with the following configuration
```javascript
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"]
},
"include": ["**/*.ts"]
}
```
* Rename the e2e spec from `*.cy.js` to `*.cy.ts`
* Rename the support files to `*.ts` files
* Rename `cypress.config.js` to `cypress.config.ts`
* Run cypress to make sure it all works as expected
* `npm run cypress:open`

# Examples

## E2E testing
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"]
},
"include": ["**/*.ts"]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"devDependencies": {
"cypress": "^12.17.3"
"cypress": "^12.17.3",
"typescript": "^5.1.6"
},
"name": "ta_docs",
"description": "This repo is used to document a bunch of test automation tools.\r The documentation is written in such a way anyone should be able to follow it.\r From installation to usage. Links to the original documentation. \r And even example code to test against (if needed).",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a4d85b7

Please sign in to comment.