Skip to content

Commit

Permalink
refactor: move test setup, add teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
jwulf committed Mar 26, 2024
1 parent 7bd2aa3 commit d256366
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"compile": "tsc --project tsconfig.json",
"docs": "rm -rf ./docs && typedoc",
"test": "jest --detectOpenHandles --testPathIgnorePatterns integration local-integration disconnection multitenancy",
"test:integration": "jest --runInBand --testPathIgnorePatterns disconnection --testPathIgnorePatterns multitenancy --detectOpenHandles --verbose true -u",
"test:multitenancy": "jest --runInBand --testPathIgnorePatterns disconnection --testPathIgnorePatterns admin - --detectOpenHandles --verbose true -u",
"test:integration": "jest --runInBand --testPathIgnorePatterns disconnection --testPathIgnorePatterns __tests__/config --testPathIgnorePatterns multitenancy --detectOpenHandles --verbose true -u",
"test:multitenancy": "jest --runInBand --testPathIgnorePatterns disconnection --testPathIgnorePatterns admin --testPathIgnorePatterns __tests__/config - --detectOpenHandles --verbose true -u",
"test:local": "jest --runInBand --verbose true --detectOpenHandles local-integration -u",
"test:local-integration": "jest --runInBand --detectOpenHandles --verbose --testPathIgnorePatterns disconnection --testPathIgnorePatterns admin --testPathIgnorePatterns multitenancy -u",
"test:docker": "jest --runInBand --testPathIgnorePatterns disconnection local-integration --detectOpenHandles --verbose true",
"test:disconnect": "jest --runInBand --verbose true --detectOpenHandles disconnection",
"test:local-integration": "jest --runInBand --detectOpenHandles --verbose --testPathIgnorePatterns disconnection --testPathIgnorePatterns admin --testPathIgnorePatterns multitenancy --testPathIgnorePatterns __tests__/config -u",
"test:docker": "jest --runInBand --testPathIgnorePatterns disconnection --testPathIgnorePatterns __tests__/config local-integration --detectOpenHandles --verbose true",
"test:disconnect": "jest --runInBand --verbose true --detectOpenHandles --testPathIgnorePatterns __tests__/config disconnection",
"test&docs": "npm test && npm run docs",
"publish": "npm run build && npm run test && lerna publish",
"commit": "cz",
Expand Down Expand Up @@ -72,7 +72,12 @@
},
"preset": "ts-jest",
"testEnvironment": "node",
"globalSetup": "<rootDir>/src/lib/jest.globalSetup.ts"
"testPathIgnorePatterns": [
"/node_modules/",
"__tests__/config/*.ts"
],
"globalSetup": "<rootDir>/src/__tests__/config/jest.globalSetup.ts",
"globalTeardown": "<rootDir>/src/__tests__/config/jest.globalTeardown.ts"
},
"config": {
"commitizen": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ require('tsconfig-paths').register()
import { OperateApiClient } from 'operate'
import { BpmnParser, ZeebeGrpcClient } from 'zeebe'

export default async () => {
export const cleanUp = async () => {
console.log('_dirname', __dirname)
console.log(process.cwd())
// Your cleanup process here.
console.log(
'Running global setup: cleanup test process instances before all tests...'
)
const filePath = path.join(__dirname, '..', '__tests__', 'testdata')
const filePath = path.join(__dirname, '..', 'testdata')
const files = fs
.readdirSync(filePath)
.map((file) => path.join(filePath, file))
Expand Down
3 changes: 3 additions & 0 deletions src/__tests__/config/jest.globalSetup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { cleanUp } from './jest.cleanup'

export default async () => cleanUp()
3 changes: 3 additions & 0 deletions src/__tests__/config/jest.globalTeardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { cleanUp } from './jest.cleanup'

export default async () => cleanUp()
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('Will throw an error if no tenantId is provided when starting a process ins
bpmnProcessId,
variables: {},
})
client.cancelProcessInstance(p.bpmnProcessId)
client.cancelProcessInstance(p.processInstanceKey)
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((e as any).code).toBe(3)
Expand Down
6 changes: 3 additions & 3 deletions src/tasklist/lib/TasklistApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ export class TasklistApiClient {
/**
* @description Assign a task with taskId to assignee or the active user.
* @throws Status 400 - An error is returned when the task is not active (not in the CREATED state).
* @throws Status 400 - An error is returned when task was already assigned, except the case when JWT authentication token used and allowOverrideAssignment = true.
* @throws Status 403 - An error is returned when user doesn't have the permission to assign another user to this task.
* @throws Status 404 - An error is returned when the task with the taskId is not found.
* Status 400 - An error is returned when task was already assigned, except the case when JWT authentication token used and allowOverrideAssignment = true.
* Status 403 - An error is returned when user doesn't have the permission to assign another user to this task.
* Status 404 - An error is returned when the task with the taskId is not found.
*/
public async assignTask({
taskId,
Expand Down

0 comments on commit d256366

Please sign in to comment.