Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
101a608
feat: add `jest` and script jest run
cesaraugustomt Nov 27, 2024
f45b8fb
style: add jest in eslint config
cesaraugustomt Nov 27, 2024
7dc26d4
build: updated port in env for 8080
cesaraugustomt Nov 27, 2024
76c6c25
feat: add script `wait-for-mariadb` and script in package
cesaraugustomt Nov 27, 2024
d293203
style: updated prettier for double quotes
cesaraugustomt Dec 3, 2024
8f79895
style: cleaning tsconfig
cesaraugustomt Dec 3, 2024
b3cb187
test: add testTimeout and collectCoverage in jest.config
cesaraugustomt Dec 3, 2024
a258b17
build: add scripts & test:ci using `concurrently` in package.json
cesaraugustomt Dec 3, 2024
caba89e
ci: add workflows `tests`
cesaraugustomt Dec 3, 2024
198242d
feat: add `orchestrator` for integration tests
cesaraugustomt Dec 3, 2024
023bb00
test: add integration test `auth` successfully login
cesaraugustomt Dec 3, 2024
807e2fa
ci: updated script start:dev in package.json
cesaraugustomt Dec 3, 2024
e3ebfae
ci: updated script start:dev in package.json
cesaraugustomt Dec 3, 2024
1e9ecc4
Merge branch 'refactor/tests-coverage' of https://github.com/cesaraug…
cesaraugustomt Dec 3, 2024
f637ef0
ci: updated script test
cesaraugustomt Dec 3, 2024
93ee7b1
test: add unit test user `CreateUseService`
cesaraugustomt Dec 3, 2024
a0c3560
feat: add .env.development
cesaraugustomt Dec 3, 2024
5edfec7
test: add unit test `DeleteUserService`
cesaraugustomt Dec 3, 2024
fb8c097
test: add unit user test `SelectByIdService`
cesaraugustomt Dec 3, 2024
6d63239
test: add unit test user `UpdateUserService`
cesaraugustomt Dec 3, 2024
b8d65b5
test: add unit test order `CreateOrderService`
cesaraugustomt Dec 3, 2024
bbee0c8
test: add unit service `DeleteOrderService`
cesaraugustomt Dec 3, 2024
db58e66
test: add unit service order `FindOrderService`
cesaraugustomt Dec 3, 2024
f42eb14
ci: updated run
cesaraugustomt Dec 3, 2024
a62927f
test: add service unit `ListOrderService`
cesaraugustomt Dec 3, 2024
de68f79
test: add unit test repositories `OrderRepository`
cesaraugustomt Dec 3, 2024
9e7b309
test: add unit test repositories `CarsRepository`
cesaraugustomt Dec 3, 2024
c1241f1
test: add unit test repositories `ClientsRepository`
cesaraugustomt Dec 3, 2024
2f3b866
refactor: updated UserController
cesaraugustomt Dec 3, 2024
b42b034
refactor: updated ClientController
cesaraugustomt Dec 3, 2024
14e71a8
test: add more test unit for UserController
cesaraugustomt Dec 3, 2024
d88b8f8
test: add unit test `AuthController`
cesaraugustomt Dec 3, 2024
254cc7e
test: add unit test `CarController`
cesaraugustomt Dec 3, 2024
bcc7184
test: add unit test `ClientController`
cesaraugustomt Dec 3, 2024
0430b2e
test: add unit test middleware `Auth`
cesaraugustomt Dec 3, 2024
aa0703c
docs: updated readme
cesaraugustomt Dec 3, 2024
4955611
ci: remove ci tests
cesaraugustomt Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ MYSQL_DATABASE=localdb
MYSQL_ROOT_PASSWORD=local_password
MYSQL_PASSWORD=localpassword

PORT=8686
PORT=8080

JWT_SECRET=67355e9965b67fd5c52d86eaf496b6794f74a01bc936ab0318f4e41b58549cf4
cc938cde930270d1ec4900a4696006a0085ecdaf7a35079b2b4a049df68d9461
10 changes: 10 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=local_user
MYSQL_DATABASE=localdb
MYSQL_ROOT_PASSWORD=local_password
MYSQL_PASSWORD=localpassword

PORT=8080

JWT_SECRET=67355e9965b67fd5c52d86eaf496b6794f74a01bc936ab0318f4e41b58549cf4
18 changes: 18 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# name: Automated Tests

# on: pull_request

# jobs:
# jest:
# name: Jest Ubuntu
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4

# - uses: actions/setup-node@v4
# with:
# node-version: "20.17.0"

# - run: npm ci

# - run: npm run test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env
.env
coverage
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"singleQuote": false,
"printWidth": 80
}
Binary file modified README.md
Binary file not shown.
4 changes: 4 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import tseslint from '@typescript-eslint/eslint-plugin';
import parser from '@typescript-eslint/parser';
import prettier from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';
import jestPlugin from 'eslint-plugin-jest';

export default [
{
Expand All @@ -15,13 +16,16 @@ export default [
sourceType: 'module',
},
globals: globals.node,
...globals.jest,
},
plugins: {
'@typescript-eslint': tseslint,
prettier: prettier,
jest: jestPlugin,
},
rules: {
...tseslint.configs.recommended.rules,
...jestPlugin.configs.recommended.rules,
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
Expand Down
214 changes: 214 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

/** @type {import('jest').Config} */
const config = {
// All imported modules in your tests should be mocked automatically
// automock: false,
testTimeout: 60000,
// Stop running tests after `n` failures
// bail: 0,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "C:\\Users\\conta\\AppData\\Local\\Temp\\jest",

// Automatically clear mock calls, instances, contexts and results before every test
// clearMocks: false,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: [
"src/**/*.ts", // Inclui todos os arquivos TypeScript na pasta src
"!src/**/*.test.ts", // Exclui arquivos de teste
"!src/**/index.ts", // Exclui arquivos de índice (se necessário)
"!src/**/*.d.ts", // Exclui definições de tipos
"!src/infra/**", // Exclui definições de tipos
"!src/application/params/**", // Exclui definições de tipos
"!src/http/dtos/**", // Exclui definições de tipos
"!src/routes/**", // Exclui definições de tipos
"!src/tests/orchestrator.ts", // Exclui definições de tipos
],

// The directory where Jest should output its coverage files
// coverageDirectory: undefined,

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// The default configuration for fake timers
// fakeTimers: {
// "enableGlobally": false
// },

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
moduleFileExtensions: [
"js",
"mjs",
"cjs",
"jsx",
"ts",
"tsx",
"json",
"node",
],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
// prefix: "<rootDir>/",
// }),

modulePaths: ["<rootDir>/src"],

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
preset: "ts-jest", // Usa ts-jest para compilar TypeScript
testEnvironment: "node",

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state before every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state and implementation before every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
// testEnvironment: "jest-environment-node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
"<rootDir>/src/tests/integration",
"<rootDir>/node_modules/",
],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "\\\\node_modules\\\\",
// "\\.pnp\\.[^\\\\]+$"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};

module.exports = config;
Loading