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