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

[🐛 Bug]: Jasmine - Skipping a test in beforeTest global hook is not preventing the test runner from executing the entire test code #11834

Closed
1 task done
HananArgov opened this issue Dec 10, 2023 · 2 comments
Labels
Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet

Comments

@HananArgov
Copy link
Contributor

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.26.0

Node.js Version

18.12.1

Mode

WDIO Testrunner

Which capabilities are you using?

{
      browserName: 'chrome',
      browserVersion: 'stable', // or 'stable', 'beta', 'dev' or 'canary'
      acceptInsecureCerts: true,
    },

What happened?

when adding
pending('skip message')
to the beforeTest hook in the config, it will not skip the test, and will continue the test

What is your expected behavior?

to skip the test.
there was a fix for mocha, i've tried to do the same for Jasmine, but the reject will fail the test.
#6645

How to reproduce the bug.

install wdio with the testrunner, and Jasmine.

in the config file add the following:

  beforeTest(test, context) {
    pending('test 123');
  },

Relevant log output

getting this from log:

[0-0] 2023-12-10T10:01:44.372Z ERROR @wdio/utils:shim: undefined


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues
@HananArgov HananArgov added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Dec 10, 2023
@HananArgov
Copy link
Contributor Author

HananArgov commented Dec 10, 2023

somehow, i've found the solution (I think)
i'm using the same solution that was used for Mocha, and I add a reason to the reject in shim.js:

            if (/^=> marked Pending/.test(e)) {
                return reject(e);
            }

the result is

 "spec" Reporter:
------------------------------------------------------------------
[firefox 64 mac #0-0] Running: firefox (v64) on mac
[firefox 64 mac #0-0] Session ID: 4b936dd8-3369-49e8-b002-c6464e5797e7
[firefox 64 mac #0-0]
[firefox 64 mac #0-0] » /e2e-specs/test/specs/example.api.ts
[firefox 64 mac #0-0] example
[firefox 64 mac #0-0]    - skipped test
[firefox 64 mac #0-0]
[firefox 64 mac #0-0]       .........Pending Reasons.........
[firefox 64 mac #0-0]          test 123
[firefox 64 mac #0-0]
[firefox 64 mac #0-0] 1 skipped (2.7s)

HananArgov added a commit to HananArgov/webdriverio that referenced this issue Dec 10, 2023
@HananArgov HananArgov changed the title [🐛 Bug]: <title> Jasmine - Skipping a test in beforeTest global hook is not preventing the test runner from executing the entire test code [🐛 Bug]: Jasmine - Skipping a test in beforeTest global hook is not preventing the test runner from executing the entire test code Dec 10, 2023
christian-bromann added a commit that referenced this issue Dec 18, 2023
#11835)

* Update shim.ts

* Update shim.ts

* adding tests

* Update tests/jasmine/test-skipped-hooks.ts

updated according to comment

Co-authored-by: Christian Bromann <git@bromann.dev>

* Update tests/helpers/jasmine-hooks.conf.js

adding comment

* fix smoke test

---------

Co-authored-by: Christian Bromann <git@bromann.dev>
@christian-bromann
Copy link
Member

Closing, thanks @HananArgov for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet
Projects
None yet
Development

No branches or pull requests

2 participants