Giter Site home page Giter Site logo

Comments (10)

srguiwiz avatar srguiwiz commented on June 4, 2024 2

@dgozman Can you please update your code example for playwright/test 0.1102.0 ?

At

import { PlaywrightEnv, newTestType, setConfig, TestInfo } from "@playwright/test";

the three imports PlaywrightEnv, newTestType, setConfig no longer exist.

Would like to follow you on the way to 1.0 by adjusting what we already have.

from playwright-test.

dgozman avatar dgozman commented on June 4, 2024 1

We have changed the underlying Folio from fixtures to environments. Sorry for the temporary hiatus - we'll become stable with v1.0 release. Let me write a snippet for you for now, and we'll update documentation soon. Following the write a configuration file section, here is an example config that gives you POM:

// config.ts

import { PlaywrightEnv, newTestType, setConfig, TestInfo } from "@playwright/test";

setConfig({
  testDir: __dirname,  // Search for tests in this directory.
  timeout: 30000,  // Each test is given 30 seconds.
});

// Extend the default environment to add any test arguments, for example POMs.
class MyEnv extends PlaywrightEnv {
  async beforeEach(testInfo: TestInfo) {
    // Get all default arguments, including Page.
    const result = await super.beforeEach(testInfo);
    // Create your POM.
    const indexPage = new IndexPage(result.page, baseURL);
    // Return default arguments and new POM.
    return { ...result, indexPage };
  }
}

// Declare "indexPage" test argument for types in IDE.
export const test = newTestType<{ indexPage: IndexPage }>();
export { expect } from "@playwright/test";

// Run tests in three browsers.
const options = {
  headless: true,  // Run tests in headless browsers.
  viewport: { width: 1280, height: 720 },
};
test.runWith(new MyEnv('chromium', options), { tag: 'chromium' });
test.runWith(new MyEnv('firefox', options), { tag: 'firefox' });
test.runWith(new MyEnv('webkit', options), { tag: 'webkit' });

Now you can use the test from the configuration file:

// foo.spec.ts

import { test, expect } from './config';

test('my test', async ({ indexPage }) => {
});

Let me know whether this works for you. Note that we are open for suggestions and work on improving test ergonomics.

from playwright-test.

srguiwiz avatar srguiwiz commented on June 4, 2024 1

@dgozman Do I understand correctly if one wants to use one's own class MyEnv extends PlaywrightEnv then one must not use ChromiumEnv, FirefoxEnv, and WebKitEnv currently mentioned in the README.md? Maybe those three browser-named Env as they exist today effectively are class hierarchy cul-de-sacs that shouldn't exist because it will be a perplexing situation for anyone who tries figuring how to build on top of them?

from playwright-test.

BillyBolton avatar BillyBolton commented on June 4, 2024

@dgozman Thank you for sending that over. Took a while to figure out fixtures properly so I was a bit worried that work was for naught.

The new config process looks promising. I wasn't clear what the TestInfo was but your comments make it more clear. I'm looking forward to the refreshed documentation down the road!

Thanks again. I'm working a lot with Playwright so I'll send some more info down the road as they come. Great stuff so far.

from playwright-test.

dgozman avatar dgozman commented on June 4, 2024

@srguiwiz Thank you for the feedback, we'll look into it.

from playwright-test.

awoloszynpetdx avatar awoloszynpetdx commented on June 4, 2024

@dgozman Can you please update your code example for playwright/test 0.1102.0 ?

At

import { PlaywrightEnv, newTestType, setConfig, TestInfo } from "@playwright/test";

the three imports PlaywrightEnv, newTestType, setConfig no longer exist.

Would like to follow you on the way to 1.0 by adjusting what we already have.

I second it.

from playwright-test.

BillyBolton avatar BillyBolton commented on June 4, 2024

I haven't checked myself but it seems from the comments that the config for v0.1102.0 is different from v0.1101.0. I understand the project is still in development though.

I'm working on a project to use playwright-test in a larger organization. Is there a roadmap I can follow / estimated time frame that the stable v1.0 might be available? This timeline affects the stakeholders of my project so any info would be appreciated, (instead of refactoring during this time).

from playwright-test.

srguiwiz avatar srguiwiz commented on June 4, 2024

@BillyBolton As original reporter of this issue you can reopen it.

from playwright-test.

BillyBolton avatar BillyBolton commented on June 4, 2024

Reopening due to popular demand 😉

(With hesitation -- I understand we're still in unstable versions.)

from playwright-test.

mxschmitt avatar mxschmitt commented on June 4, 2024

We now have an official example for using the POM pattern with the new test-runner which got released yesterday. See here for the example.

from playwright-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.