Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Multiple status code exclusion in if statement in webhook #2142

@ivanmikhalka

Description

@ivanmikhalka

Describe the bug
In my tests I am going to execute only GET requests which expected 200 and 403 response codes, and skip all the rest. Trying to
achieve this via dreddhook. I can easily exclude all except one status code, but when I use multiple OR condition, result confuses me.

This works fine:

hooks.beforeEach(function (transaction) {
	if(transaction.expected.statusCode !== "403" || transaction.request.method !== "GET") {
		transaction.skip = true;
	} 
});

This exclude ALL tests:

hooks.beforeEach(function (transaction) {
	if(transaction.expected.statusCode !== "200" || transaction.expected.statusCode !== "403" || transaction.request.method !== "GET") {
		transaction.skip = true;
	} 
});

To Reproduce
I have openapi.yml, dredd.yml config, dreddhooks.js and running test via command
docker run -it -v $PWD:/api -w /api apiaryio/dredd dredd

Expected behavior
Exclude all except I have in if condition

What is in your dredd.yml?

reporter: html
dry-run: null
hookfiles: "dreddhooks.js"
loglevel: debug
blueprint: openapi.yml
endpoint: http://host.docker.internal:8080/myapi
path: []

What's your dredd --version output?

v14.17.0

Does dredd --loglevel=debug uncover something?
I am using debug level from the beginning

Can you send us failing test in a Pull Request?
Cannot

Output for first case (ok)
Screenshot 2022-11-22 at 17 50 31

Output for second case (wrong)
Screenshot 2022-11-22 at 17 52 30

P.S. All running tests are failing as I recorded these screenshot with switched off API, but it's not really matter in current case, as test is skipping.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions