Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Can I use Jest framework to assert? #3889

Closed
Shyam-Chen opened this issue Dec 29, 2016 · 5 comments
Closed

Can I use Jest framework to assert? #3889

Shyam-Chen opened this issue Dec 29, 2016 · 5 comments

Comments

@Shyam-Chen
Copy link
Contributor

Shyam-Chen commented Dec 29, 2016

Jest seems like Jasmine.

Jest support for testing with promises and async/await.

[...]
  beforeEach(async () => {
    await browser.driver.get('http://localhost:9876/en/home');
  });

  it('should be able to get the text', () => {
    let el = webdriver.findElement(by.css('h2.mdl-color-text--blue-900'));
    expect(el.getText()).toEqual('Home');
  });
[...]
@juliemr
Copy link
Member

juliemr commented Dec 29, 2016

We have not experimented with using Jest yet, and we don't have built-in support for it. However, you can write and use a custom adapter a framework following the instructions in the README at https://github.com/angular/protractor/tree/master/lib/frameworks

@NickTomlin
Copy link
Contributor

I'm going to go ahead and close this since there hasn't been much activity on it. I think we'd accept a pull request if folks want to add a framework adapter for Jest.

@winnemucca
Copy link

Was this ever added?

@marcus-sa
Copy link

So.... what's the update on this?

@andredesousa
Copy link

Hi, it´s possible because Jest exports your assertion library. For more details:

https://jestjs.io/docs/en/expect

So, we can configure it in the onPrepare function:

onPrepare() {
  global.expect = require('expect');
},

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

No branches or pull requests

6 participants