Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple status code exclusion in if statement in webhook #2142

Open
ivanmikhalka opened this issue Nov 22, 2022 · 0 comments
Open

Multiple status code exclusion in if statement in webhook #2142

ivanmikhalka opened this issue Nov 22, 2022 · 0 comments

Comments

@ivanmikhalka
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant