From 6ca015d7622f12bba713cf11bea4c56de54b5fd1 Mon Sep 17 00:00:00 2001 From: omerose Date: Fri, 14 Jun 2019 15:01:30 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20correct=20tsconfig=20instr?= =?UTF-8?q?uctions=20for=20cypress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Edited README only. Why? I followed the instructions and it didn't work with recent changes to official instructions from Cypress-typescript I installed last week. So these documentation will help out anyone doing this today. I also found the types file to be handy for all library definitions, so I added it into the README --- docs/cypress-testing-library/intro.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/cypress-testing-library/intro.md b/docs/cypress-testing-library/intro.md index 4fcf3da49..614626d19 100644 --- a/docs/cypress-testing-library/intro.md +++ b/docs/cypress-testing-library/intro.md @@ -22,11 +22,32 @@ Add this line to your project's `cypress/support/commands.js`: import '@testing-library/cypress/add-commands'; ``` +## With typescript +Typings are defined under @testing-library/cypress/typings, and should be added as follows in tsconfig.json: + +```json +{ + "compilerOptions": { + "types": ["cypress", "../@testing-library/cypress/typings"] + } +} +``` +or if tsconfig.json has a `baseUrl` of `../node_modules` as recommended in the official Cypress documentation use: +```json +{ + "compilerOptions": { + "types": ["cypress", "@testing-library/cypress/typings"] + } +} +``` + You can now use all of `DOM Testing Library`'s `getBy`, `getAllBy`, `queryBy` and `queryAllBy` commands. [See `DOM Testing Library` API for reference](dom-testing-library/api-queries.md) ## Examples +You can find [all Library definitions here](https://github.com/testing-library/cypress-testing-library/blob/master/typings/index.d.ts). + To show some simple examples (from [https://github.com/testing-library/cypress-testing-library/blob/master/cypress/integration/commands.spec.js](https://github.com/testing-library/cypress-testing-library/blob/master/cypress/integration/commands.spec.js)):