Skip to content

Commit

Permalink
throw exeception if it throw by the function but not expected in test (
Browse files Browse the repository at this point in the history
…#32)

* throw exeception if it throw by the function but not expected in test

* bump version

---------

Co-authored-by: Ab <[email protected]>
  • Loading branch information
fantazista and abdala authored Nov 26, 2024
1 parent 6eb4d40 commit b5f15bb
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion assert/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/assert",
"version": "0.10.2",
"version": "0.10.3",
"description": "Extra assert library",
"type": "module",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion dtc-aws-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc-aws-plugin",
"version": "0.10.2",
"version": "0.10.3",
"description": "AWS plugin for Declarative TestCases",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion dtc-graphql-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc-graphql-plugin",
"version": "0.10.2",
"version": "0.10.3",
"description": "GraphQl plugin for Declarative TestCases",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion dtc-mysql-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc-mysql-plugin",
"version": "0.10.2",
"version": "0.10.3",
"description": "MySQL plugin for Declarative TestCases",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion dtc-playwright-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc-playwright-plugin",
"version": "0.10.2",
"version": "0.10.3",
"description": "Playwright plugin for Declarative TestCases",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion dtc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc",
"version": "0.10.2",
"version": "0.10.3",
"description": "Declarative TestCases",
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion dtc/src/plugins/function-call-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export const assert = (args: unknown) => {
}

nodeAssert.equal(args.exception.name, exception.name)
}
} else {
if (exception) {
throw exception
}
}

if (response) {
extraAssert.objectContains(response, args)
Expand Down
20 changes: 20 additions & 0 deletions dtc/test/plugins/function-call-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {test} from 'node:test'
import {act, assert} from '../../src/plugins/function-call-plugin'
import {dirname} from 'node:path'
import {fileURLToPath} from 'node:url'
import nodeAssert from 'node:assert'

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -53,3 +54,22 @@ test('It call a sync function with exception', async () => {

assert(args)
})

test('It call a sync function and throw exception if id does not exist in assert', async () => {
const args = {}

await act(
{
import: 'functionWithException',
from: '../fixtures/functions.js',
arguments: [args],
},
__dirname,
)

try {
assert(args)
} catch (e) {
nodeAssert.ok(true)
}
})
2 changes: 1 addition & 1 deletion nock-aws/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/nock-aws",
"version": "0.10.2",
"version": "0.10.3",
"description": "AWS Request mocker based on Nock",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion type-guard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/type-guard",
"version": "0.10.2",
"version": "0.10.3",
"description": "Typescript type guards",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion yaml/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/yaml",
"version": "0.10.2",
"version": "0.10.3",
"description": "YAML parser with extra tags",
"repository": {
"type": "git",
Expand Down

0 comments on commit b5f15bb

Please sign in to comment.