From f8b5d57e397bb2954e51a06b277f06627fafd922 Mon Sep 17 00:00:00 2001 From: alainn-n Date: Tue, 30 Aug 2022 23:30:54 -0300 Subject: [PATCH] =?UTF-8?q?Entrega=20Exerc=C3=ADcios=20-=20Aula=20Testes?= =?UTF-8?q?=20automatizados=20com=20Typescript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modulo7/testes-automatizados/.gitignore | 0 modulo7/testes-automatizados/jest.config.js | 8 +++++++ modulo7/testes-automatizados/package.json | 23 ++++++++++++++++++++ modulo7/testes-automatizados/src/index.ts | 24 +++++++++++++++++++++ modulo7/testes-automatizados/tsconfig.json | 13 +++++++++++ 5 files changed, 68 insertions(+) create mode 100644 modulo7/testes-automatizados/.gitignore create mode 100644 modulo7/testes-automatizados/jest.config.js create mode 100644 modulo7/testes-automatizados/package.json create mode 100644 modulo7/testes-automatizados/src/index.ts create mode 100644 modulo7/testes-automatizados/tsconfig.json diff --git a/modulo7/testes-automatizados/.gitignore b/modulo7/testes-automatizados/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/modulo7/testes-automatizados/jest.config.js b/modulo7/testes-automatizados/jest.config.js new file mode 100644 index 0000000..cf45f3a --- /dev/null +++ b/modulo7/testes-automatizados/jest.config.js @@ -0,0 +1,8 @@ +module.exports = { + roots: ["/tests"], + transform: { + "^.+\\.tsx?$": "ts-jest", + }, + testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", + moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], + }; \ No newline at end of file diff --git a/modulo7/testes-automatizados/package.json b/modulo7/testes-automatizados/package.json new file mode 100644 index 0000000..7182c0a --- /dev/null +++ b/modulo7/testes-automatizados/package.json @@ -0,0 +1,23 @@ +{ + "name": "jest-template", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "dev": "ts-node-dev ./src/index.ts", + "test": "jest" + }, + "author": "", + "license": "ISC", + "dependencies": { + + }, + "devDependencies": { + "@types/jest": "^28.1.3", + "jest": "^28.1.1", + "ts-jest": "^28.0.5", + "@types/node": "^14.0.6", + "ts-node-dev": "^1.0.0-pre.44", + "typescript": "^4.6.3" + } + } \ No newline at end of file diff --git a/modulo7/testes-automatizados/src/index.ts b/modulo7/testes-automatizados/src/index.ts new file mode 100644 index 0000000..fc4b61e --- /dev/null +++ b/modulo7/testes-automatizados/src/index.ts @@ -0,0 +1,24 @@ + +Viewed +@@ -0,0 +1,21 @@ + +export const isEven = (n: number): any => { + return n % 2 === 0; +} + +export const myAsyncFunc = async ():Promise => { + return "response"; +}; + +export const login = async (password: string): Promise => { + + if (password !== "senha correta"){ + throw new Error("A senha está incorreta") + } + + return { + id: 1, + name: "teste" + } + +} \ No newline at end of file diff --git a/modulo7/testes-automatizados/tsconfig.json b/modulo7/testes-automatizados/tsconfig.json new file mode 100644 index 0000000..7d51728 --- /dev/null +++ b/modulo7/testes-automatizados/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es6" , + "module": "commonjs", + "outDir": "./build" , + "rootDir": "./" , + "strict": true , + "sourceMap": true, + "removeComments": true, + "esModuleInterop": true , + "forceConsistentCasingInFileNames": true + } + } \ No newline at end of file