Testing puppeteer with Jasmine?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 15:53:03

问题


We have a website that has many paths of flow (login , signup , payment ,etc)

We're using puppeteer scripts ( typescript via node) to automate-testing our website behaviour (full flow) , and when we get an error (or unexpected result) we're sending email or some kind of alerts.

But I see that people also use jasmine with puppeteer.

For example :

const puppeteer = require('puppeteer');

describe("Jasmine puppeteer", function() {

  let browser;
  let page;

  beforeAll(() => {
    browser = await puppeteer.launch({headless: false});
    page = await browser.newPage();
    await page.goto('chrome://newtab');
    await page.screenshot({path: 'a.png'});
  })

  it("jasmine puppeteer", () => {
    expect(await page.title()).toBe("");
    done();
  });

  afterAll(() => {
  })
});

Using a testing framework over automated testing framework seems (to me) like Test(Test())

Question

Should we change our site approach testing to jasmin over puppeteer ? I mean , currently puepetteer provides a good way to test our site flow. Should we need to apply jasmine testing over our existing tests scripts ? I'm a bit confused about that.


回答1:


You can use jest with puppeteer for end to end testing. Jest is based on Jasmine framework. It is developed by Facebook and it’s quite popular now.




回答2:


puppeteer is not a testing framework. puppeteer is a tool that automate browser. you cannot make any assert with puppeteer, so you need a testing framework. a good choise for puppeteer is jest, because jest come out of the box with everything you need. you can also use mocha and chai, but i suggest jest because you can start to use immediately.



来源:https://stackoverflow.com/questions/53459478/testing-puppeteer-with-jasmine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!