playwright/docs/src/test-api
Dmitry Gozman d9f849fb14
feat(test runner): replace declare/define with "options" (#10293)
1. Fixtures defined in test.extend() can now have `{ option: true }` configuration that makes them overridable in the config. Options support all other properties of fixtures - value/function, scope, auto.
```
const test = base.extend<MyOptions>({
  foo: ['default', { option: true }],
});
```

2. test.declare() and project.define are removed.

3. project.use applies overrides to default option values and nothing else. Any test.extend() and test.use() calls take priority over config options.

Required user changes: if someone used to define fixture options with test.extend(), overriding them in config will stop working. The solution is to add `{ option: true }`.

```
// Old code
export const test = base.extend<{ myOption: number, myFixture: number }>({
  myOption: 123,
  myFixture: ({ myOption }, use) => use(2 * myOption),
});

// New code
export const test = base.extend<{ myOption: number, myFixture: number }>({
  myOption: [123, { option: true }],
  myFixture: ({ myOption }, use) => use(2 * myOption),
});
```
2021-11-18 15:45:52 -08:00
..
class-fixtures.md chore(fetch): rename ApiRequest* to APIRequest* (#9606) 2021-10-19 07:38:27 -07:00
class-test.md feat(test runner): replace declare/define with "options" (#10293) 2021-11-18 15:45:52 -08:00
class-testconfig.md docs/test-config: add github, html reporter (#10234) 2021-11-12 06:50:56 -08:00
class-testerror.md docs(test runner): api reference for reporter api (#7811) 2021-07-22 19:56:36 -07:00
class-testinfo.md fix(test runner): update TestInfo.duration before running afterEach hooks (#10228) 2021-11-10 16:02:27 -08:00
class-testoptions.md feat(test-runner): allow specifying fine-grained trace options (#10147) 2021-11-08 15:39:58 -08:00
class-testproject.md feat: add snapshotDir to set base snapshot directory (#9260) 2021-11-02 08:02:49 -07:00
class-workerinfo.md feat(test runner): introduce TestInfo.parallelIndex (#9762) 2021-11-01 10:37:34 -07:00