Commit Graph

185 Commits

Author SHA1 Message Date
Jack Franklin
8fa034bf2f
chore: remove flakiness dashboard (#5592)
We're not using it at all so might as well cut down on code in the codebase.
2020-04-06 11:55:15 +02:00
Jack Franklin
4ee2c43f06
chore: fix Page.emulateMedia doclint failure (#5584)
This is expected as we now alias `emulateMedia` in `index.js` which isn't a file checked by DocLint. We alias there to avoid having the function overriden by the `asyncInstallHooks` code.

This commit updates doclint to know about methods that we expect it will find are missing and in that case just skip over them. We should only do this for methods where we plan to deprecate them or we have to define them in an odd way to work around some problem (and if that's the case long term we should fix that problem so we can define them as normal).

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-04-06 10:38:05 +02:00
Jack Franklin
88446df724
chore: fix missed src/ vs lib/ documentation (#5591)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-04-06 10:32:42 +02:00
Tim Gates
99ecdbad0a
docs: fix simple typo (#5585)
There is a small typo in test/utils.js, utils/flakiness-dashboard/FlakinessDashboard.js.

Should read `existence` rather than `existance`.
2020-04-06 08:49:15 +02:00
Jack Franklin
6522e4f524
chore: Use expect for assertions (#5581)
Rather than use our own custom expect library, we can use expect from npm [1], which has an API almost identical to the one Puppeteer has, but with more options, better diffing, and is used by many in the community as it's the default assertions library that comes with Jest.

It's also thoroughly documented [2].

[1]: https://www.npmjs.com/package/expect
[2]: https://jestjs.io/docs/en/expect
2020-04-03 13:22:55 +02:00
Jack Franklin
7a2a41f208
chore: move code to src/ and emit with TypeScript (#5568)
This updates our `tsconfig.json` so it emits our JavaScript files as
well as type checking them. We compile into `./lib` which we then ship
in our npm package. The source code has moved from `./lib` into `./src`.

Because the `src/` directory is exclusively JS files, this change is a
no-op in terms of code functionality but is the first step towards being
able to replace `src/X.js` with `src/X.ts` in a way that allows us to
migrate incrementally.

The `lib` directory is gitignored, and the `src` directory is
npmignored. On `npm publish` we will now run `npm run tsc` in order to
generate the outputted code.
2020-04-02 16:25:19 +02:00
Jack Franklin
4b0fd8bc30
chore: upgrade to TypeScript 3.7 (#5562)
TypeScript seems to struggle to understand `Promise.all` when the items in the array return different types. If we were authoring in TS we could fix this with TS generics (`Promise.all<OurTypeHere>(...)`) but for now we can typecast the result. We'll fix this properly when we author in TS.
2020-03-31 18:42:32 +02:00
Jack Franklin
5e8d79bf98
chore: upgrade to TypeScript 3.5 (#5556)
TS 3.5 got much stricter on writing changes to objects with varied types [1] so we have to do a bit of typecasting work to convince TS about the types of keys and values that we are setting.

Longer term we should think about a better data structure that avoids us having to jump through some hoops but for now I think this is a reasonable step to get us onto 3.5.

Same story regarding bindings on `window`: the easiest fix is to cast `window` to `any` for the code that adds to it. I'm sure we can come up with a more type-safe way of doing this in the future.

[1]: https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#fixes-to-unsound-writes-to-indexed-access-types
2020-03-31 10:48:09 +02:00
Grzegorz (Greg) Ziółkowski
0d243b7a0f feat: make it possible to run install.js script with puppeteer-core (#5325)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-01-28 13:08:13 +01:00
Mathias Bynens
eddb23b521
chore: update URLs (#5185) 2019-11-26 13:12:25 +01:00
Maja Frydrychowicz
c5a72e9887 feat(launcher): add option to run Puppeteer with different browsers (#5137)
* feat: Set which browser to launch via PUPPETEER_PRODUCT

This change introduces a PUPPETEER_PRODUCT environment
variable as a first step toward using Puppeteer with
many different browsers. Setting PUPPETEER_PRODUCT=firefox, for
example, enables Firefox-specific Launcher settings.

The state is also exposed as `puppeteer.product` in the API
to support adding other product-specific behaviour as needed.

The bulk of the change is a refactoring in Launcher
to decouple generic browser start-up from product-specific
configuration.

Respecting the puppeteer-core restriction for PUPPETEER_
environment variables, lazily instantiate the Launcher
based on a `product` Puppeteer.launch option, if available.

* test: Distinguish Juggler unit tests from Firefox

The funit script is renamed to fjunit (j for Juggler, which is
used only by the experimental puppeteer-firefox package.

In contrast, the funit script now refers to running Puppeteer
unit tests against the main puppeteer package with Firefox.
To do so with Firefox Nightly, run:

`BINARY=path/to/firefox npm run funit`

A number of changes in this patch make it easier to run
Puppeteer unit tests in Mozilla's CI.
2019-11-26 10:23:19 +01:00
Connor Clark
d17708ba1f fix(types): publish protocol types to npm (#5174)
Co-Authored-By: Mathias Bynens <mathias@qiwi.be>
2019-11-15 20:19:08 -08:00
Mathias Bynens
11ff374ca3
chore: drop Node.js v6 support (#5045)
Node.js v6 was end-of-life'd in April, 2019, with AWS Lambda prohibiting updaets to the Node.js v6 runtime since June 30, 2019.

This makes it quite safe for us to remove the Node 6 support from the repository.
2019-10-16 17:00:20 +02:00
Andrey Lushnikov
faa452718e
chore(testrunner): bump TestRunner version to v0.8.0 (#4856) 2019-08-17 22:02:40 -07:00
Andrey Lushnikov
2871bcd57d
chore(bisect): inherit parent ENV when launching script (#4842) 2019-08-13 16:28:09 -07:00
Andrey Lushnikov
763e3901d9
chore(flaky): save build result (#4819) 2019-08-08 20:53:12 -07:00
Andrey Lushnikov
608b15f20d
chore(flakiness): limit max builds to 100 (#4818)
This was missing in #4808
2019-08-08 15:15:33 -07:00
Andrey Lushnikov
f753ec6b04
chore(testrunner): distinguish between TERMINATED and CRASHED (#4821)
`testRunner.run()` might have 4 different outcomes:
- `ok` - all non-skipped tests passed
- `failed` - some tests failed or timed out
- `terminated` - process received SIGHUP/SIGINT while testrunner was running tests. This happens on CI's under certain circumstances, e.g. when
  VM is getting re-scheduled.
- `crashed` - testrunner terminated test execution due to either `UnhandledPromiseRejection` or
  some of the hooks (`beforeEach/afterEach/beforeAll/afterAll`) failures.

As an implication, there are 2 new test results: `terminated` and `crashed`.
All possible test results are:
- `ok` - test worked just fine
- `skipped` - test was skipped with `xit`
- `timedout` - test timed out
- `failed` - test threw an exception while running
- `terminated` - testrunner got terminated while running this test
- `crashed` - some `beforeEach` / `afterEach` hook corresponding to this
test timed out of threw an exception.

This patch changes a few parts of the testrunner API:
- `testRunner.run()` now returns an object `{result: string,
terminationError?: Error, terminationMessage?: string}`
- the same object is dispatched via `testRunner.on('finished')` event
- `testRunner.on('terminated')` got removed
- tests now might have `crashed` and `terminated` results
- `testRunner.on('teststarted')` dispatched before running all related
`beforeEach` hooks, and `testRunner.on('testfinished')` dispatched after
running all related `afterEach` hooks.
2019-08-08 15:15:09 -07:00
Andrey Lushnikov
dcff850b6f
chore(flakiness): update flakiness format (#4808)
This patch:
- updates Flakiness Dashboard format to define version per-build
  and to pass COMMIT information
- drops the README.md generation - we'll move on to a designated flakiness
  dashboard viewer
2019-08-06 15:32:55 -07:00
Andrey Lushnikov
f733c334dc
chore(flakiness): revert compression for dashboard.json (#4794)
Compression wins turned out to be 20KB instead of 200KB as I initially
thought.
2019-08-01 16:40:29 -07:00
Andrey Lushnikov
e252dcf200
chore(flakiness): Flakiness Dashboard fixes (#4788)
- fix `FLAKINESS_DASHBOARD_BUILD_URL` to point to a task instead of a build
- do not pretty-print `dashboard.json` when serializing flakiness results
- filter out 'COVERAGE' test(s) so that they don't add up to `dashboard.json` payload. These are useless
- validate certain important options of flakiness dashboard
- more logging to STDOUT to actually say which repo and what branch is getting used
- enhance commit message with a build URL
- use a more compact format for JSON. For 100 runs of 700 tests it yields 21MB json instead of 23MB.
- bump default builds number to 100
2019-08-01 16:09:02 -07:00
Andrey Lushnikov
932c8cbe9a
chore: introduce initial version of flakiness dashboard (#4781)
This patch introduces a dashboard that records test results and
uploads them to https://github.com/aslushnikov/puppeteer-flakiness-dashboard

Since many bots might push results in parallel, each bot pushes
results to its own git branch.

FlakinessDashboard also generates a simple README.md with a flakiness
summary. If this proves to be not enough, we can build a website that
fetches flakiness data and renders it nicely.
2019-07-31 22:23:50 -07:00
Andrey Lushnikov
7406b185d2
chore(testrunner): introduce tests for TestRunner (#4773)
This adds some basic tests for the test runner.
2019-07-30 13:19:12 -07:00
Andrey Lushnikov
3bbc45af8b
chore: improve //utils/check_availability.js (#4770)
This patch teaches `//utils/check_availability.js` to break
when it is run with no arguments and it finds an available revision.
2019-07-29 14:29:50 -07:00
Andrey Lushnikov
3982a603cc
chore(testrunner): bump TestRunner version to v0.7.0 (#4719) 2019-07-18 11:25:27 -07:00
Andrey Lushnikov
852c46c1e4
feat(testrunner): async suite descriptions (#4721)
This patch teaches TestRunner to support async suite
descriptions. This is needed to require tests using ES6 dynamic
imports:

```js
const t = new TestRunner();

await t.describe('tests', async () => {
  (await import('./some.spec.js')).addTests(t);
  (await import('./other.spec.js')).addTests(t);
});
```
2019-07-18 11:25:06 -07:00
Andrey Lushnikov
835e8849fd
feat(testrunner): add new testrunner options (#4718)
This patch adds new TestRunner options:
- `disableTimeoutWhenInspectorIsEnabled` - disable test timeout if
  testrunner detects enabled inspector.
- `breakOnFailure` - if testrunner should terminate test running on
  first test failure
2019-07-17 10:32:37 -07:00
Andrey Lushnikov
934d73e526
fix(testreporter): Test Reporter should not terminate node.js process (#4716)
This patch starts assigning process exit codes rather than terminating
parent process. Library should never own/terminate parent node.js
process.
2019-07-16 16:34:41 -07:00
Andrey Lushnikov
eea55bd6c6
fix(testrunner): properly handle testrunner terminations (#4717)
This patch improves the logic for test runner termination.
With this patch:
- TestRunner runs all afterEach/afterAll hooks when a
termination happens, properly terminating browser instances
- TestRunner cleans up all dangling timeout timers so that node.js
process is not retained and is free to exit
2019-07-16 16:26:03 -07:00
Yury Semikhatsky
a39d553511 fix(tests): Get TLS version from Node instead of hardcoding it (#4700) 2019-07-14 18:33:31 -07:00
Andrey Lushnikov
a582c11b1b
chore(ci): add Node10 and Node12 to Cirrus (#4699) 2019-07-13 23:22:02 -07:00
Andrey Lushnikov
a17c727b78
chore: release next testrunner (#4697) 2019-07-12 12:50:48 -07:00
Andrey Lushnikov
e3abb0aa32
feat(puppeteer): introduce puppeteer.errors and puppeteer.devices (#4312)
These getters are introduced as a more convenient substitute for
a `require('puppeteer/Errors')` and
`require('puppeteer/DeviceDescriptors')`.

This way we can make cross-browser story nicer - a single require
of `puppeteer` or `puppeteer-firefox` fully defines Puppeteer
environment.
2019-04-19 15:33:06 -07:00
Andrey Lushnikov
080b80975f
docs(contributing): add instructions to build Chromium revisions (#4246) 2019-04-04 15:34:41 -07:00
Andrey Lushnikov
0adffcc2cb
docs: add table-of-contents to troubleshooting (#4234)
Drive-by: teach our table-of-contents generator to ignore comments
inside fenced blocks and to de-linkify titles.
2019-04-02 19:08:22 -07:00
Andrey Lushnikov
3511a35fa4
test: fix fixtures test when run with env DUMPIO=1 (#4123)
The DUMPIO env variable is propagated to a spawned process
and results in unfortunate stdout.
2019-03-13 16:26:28 -07:00
Andrey Lushnikov
42351c7fe5
feat(firefox): Implement header overrides in request interception (#4142)
This patch makes sure header overrides in request interception are
functioning as expected.

Drive-by: teach test server to use utf-8 charset header for text files.
2019-03-08 14:26:13 -08:00
Andrey Lushnikov
1623bef264
test: improve test coverage for Request.continue (#4096)
Drive-by: add clarification to docs/api.md regarding
chaning "URL".

References #4030
2019-03-05 14:57:15 -08:00
Andrey Lushnikov
56dafd7424
feat: support Response.buffer(), Response.json() and Response.text() (#4063)
This patch:
- implements Response.buffer() and other methods
- splits out relevant tests into a separate test suites
- implements `testServer.enableGzip()` method to optionally gzip
  certain routes in tests
- adds tests to make sure `Response.text()` returns expected results
  for binary and compressed responses.
2019-02-24 19:31:35 -08:00
Andrey Lushnikov
57e7f12fbc
test: split out tests for security details (#3996)
This adds missing test coverage for security details and
re-generates our self-signed ceritificate to have meaningful
issuer and subject name.
2019-02-13 11:35:49 -08:00
Andrey Lushnikov
569609636e
chore(testrunner): newline for toEqual matcher (#3959) 2019-02-08 16:18:45 -08:00
Andrey Lushnikov
9216056d12
fix(testrunner): fix bad test counter (#3947) 2019-02-07 13:26:35 -08:00
Andrey Lushnikov
addd7f4c6a
chore(testrunner): introduce verbose mode (#3946) 2019-02-07 13:17:29 -08:00
Andrey Lushnikov
6887ad881a
chore: further unify Puppeteer-Firefox tests with Puppeteer (#3931)
This patch:
* unifies assets between tests
* enables a few puppeteer tests on Puppeteer-Firefox

Drive-by: beautify failing output of `expect.toEqual` matcher.

References #3889
2019-02-06 13:49:14 -08:00
Andrey Lushnikov
14fb3e38db
chore(firefox): mark all Puppeteer tests that are failing on FF (#3924)
This patch:
- introduces new testRunner methods `addTestDSL` and `addSuiteDSL`
  to add annotated test / suite.
- introduces new test/suite declaration methods: `it_fails_ffox` and
  `describe_fails_ffox`. These are equal to `it`/`describe` for chromium
  tests and to `xit`/`xdescribe` for firefox.
- marks all unsupported tests with `it_fails_ffox`
- adds a new command-line flag `'--firefox-status'` to `//test/test.js`.
  This flag dumps current amount of tests that are intentionally skipped
  for Firefox.

End goal: get rid of all `it_fails_ffox` and `describe_fails_ffox`
tests.

Drive-By: remove cookie tests  "afterEach" hook that was removing
cookies - it's not needed any more since every test is run in a
designated browser context.

References #3889
2019-02-05 22:32:41 -08:00
Andrey Lushnikov
bc71e9236d
chore(testrunner): nicer colors for test reporter (#3921) 2019-02-05 19:02:29 -08:00
Andrey Lushnikov
a210dd7ee2
chore(testrunner): show 5 slowest tests on CI (#3919)
Show top slowest tests on CI.

Drive-by: some facelifting for the test reporter.
2019-02-05 15:28:35 -08:00
Joel Einbinder
5cca7c0cae fix(types): don't report events as class members (#3874) 2019-01-31 17:53:16 -08:00
Joel Einbinder
f2c968fdb8 chore(types): generate our own d.ts file from api.md (#3744)
Generate `//index.d.ts` file with precise typescript definitions for all of the
Puppeteer API.
2019-01-28 15:12:45 -08:00
Andrey Lushnikov
62da2366c6
chore: introduce //lib/api.js (#3835)
Introduce `//lib/api.js` that declares a list of publicly exposed
classes.

The `//lib/api.js` list superceedes dynamic `helper.tracePublicAPI()` calls
and is used in the following places:
- [ASYNC STACKS]: generate "async stacks" for publicy exposed API in `//index.js`
- [COVERAGE]: move coverage support from `//lib/helper` to `//test/utils`
- [DOCLINT]: get rid of 'exluded classes' hardcoded list

This will help us to re-use our coverage and doclint infrastructure
for Puppeteer-Firefox.

Drive-By: it turns out we didn't run coverage for `SecurityDetails`
class, so we lack coverage for a few methods there. These are excluded
for now, sanity tests will be added in a follow-up.
2019-01-25 23:21:14 -05:00