{"_id":"@cybernaut/puppeteer","_rev":"11-904a7891e7e192889dc7c9061c5de62c","name":"@cybernaut/puppeteer","description":"Convenience functions for using Puppeteer with @cybernaut/test.","dist-tags":{"latest":"15.1.0"},"versions":{"15.0.0-0":{"name":"@cybernaut/puppeteer","version":"15.0.0-0","description":"Convenience functions for using Puppeteer with @cybernaut/test.","license":"MIT","author":{"name":"Clemens Akens","email":"clebert@me.com"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"files":["lib","types"],"dependencies":{"@cybernaut/test":"^15.0.0-0","puppeteer":"^0.10.2"},"_id":"@cybernaut/puppeteer@15.0.0-0","scripts":{},"_shasum":"f8cd02c347d16bd72f45d2987f7d44714778b4be","_from":".","_npmVersion":"3.10.10","_nodeVersion":"8.1.4","_npmUser":{"name":"clebert","email":"clebert@me.com"},"dist":{"shasum":"f8cd02c347d16bd72f45d2987f7d44714778b4be","tarball":"https://registry.npmjs.org/@cybernaut/puppeteer/-/puppeteer-15.0.0-0.tgz","integrity":"sha512-sAuK/dcey2FHoOcWVYXOSd7wAmdcnmejQpJ9J4a6/3qE2LQEbGD2Svg9MZUOpCR69MSEmV/LtuOgsC/aVW+knA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDnsZ8hvbtcMAFUnGte/joEX2mzvHue/42H0vXdp1XxEAiByQamC8IItLl7Ulxehldgc76mokVLeOYQw5SZfcc9w7Q=="}]},"maintainers":[{"name":"clebert","email":"clebert@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/puppeteer-15.0.0-0.tgz_1505124481110_0.3544021896086633"}},"15.0.0-1":{"name":"@cybernaut/puppeteer","version":"15.0.0-1","description":"Convenience functions for using Puppeteer with @cybernaut/test.","license":"MIT","author":{"name":"Clemens Akens","email":"clebert@me.com"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"files":["lib","types"],"dependencies":{"@cybernaut/test":"^15.0.0-0","puppeteer":"^0.10.2"},"_id":"@cybernaut/puppeteer@15.0.0-1","scripts":{},"_shasum":"63206a4f77db2a0ac6f9904852fab5660cce828c","_from":".","_npmVersion":"3.10.10","_nodeVersion":"8.1.4","_npmUser":{"name":"clebert","email":"clebert@me.com"},"dist":{"shasum":"63206a4f77db2a0ac6f9904852fab5660cce828c","tarball":"https://registry.npmjs.org/@cybernaut/puppeteer/-/puppeteer-15.0.0-1.tgz","integrity":"sha512-OkpBceQuh7VCJgtq3JUWWVSQAGKgo/+yqvFKtHp+O4j3lrugkThtsr66mqf6w0U40yvCuQiZYqABQWHc87fDRg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDdyQudPFp7BicKvceUzXPdJU649x+75JfBhXmpkC5FPAIhAK38qNVxlPk3EVdlLTuB5ZJHQlqw7i8q6Q0XNYCIcoPi"}]},"maintainers":[{"name":"clebert","email":"clebert@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/puppeteer-15.0.0-1.tgz_1505158777652_0.673710192553699"}},"15.0.0-2":{"name":"@cybernaut/puppeteer","version":"15.0.0-2","description":"Convenience functions for using Puppeteer with @cybernaut/test.","license":"MIT","author":{"name":"Clemens Akens","email":"clebert@me.com"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"files":["lib","types"],"dependencies":{"@cybernaut/test":"^15.0.0-0","puppeteer":"^0.10.2"},"_id":"@cybernaut/puppeteer@15.0.0-2","scripts":{},"_shasum":"e1bfd64a7cae6969501f091e8713947e5404a8cd","_from":".","_npmVersion":"3.10.10","_nodeVersion":"8.1.4","_npmUser":{"name":"clebert","email":"clebert@me.com"},"dist":{"shasum":"e1bfd64a7cae6969501f091e8713947e5404a8cd","tarball":"https://registry.npmjs.org/@cybernaut/puppeteer/-/puppeteer-15.0.0-2.tgz","integrity":"sha512-P65ei0q8+jRAqXshwgYb70ELCK5Aol/CkO6t+uTDD6D1w2Pe5X3K6JZuEvH9lHra3wJ40LyA51AbqgqRqi7sig==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICYHjK7S9lKhMwI78+iIAH58gLOH2JDanu0cq/QnUp21AiEA7/P0KkSf4iBSqD96PSKrOA4PH+CGFYRrv381IAFVheo="}]},"maintainers":[{"name":"clebert","email":"clebert@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/puppeteer-15.0.0-2.tgz_1505159714124_0.24297286896035075"}},"15.0.0-3":{"name":"@cybernaut/puppeteer","version":"15.0.0-3","description":"Convenience functions for using Puppeteer with @cybernaut/test.","license":"MIT","author":{"name":"Clemens Akens","email":"clebert@me.com"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"files":["lib","types"],"dependencies":{"@cybernaut/test":"^15.0.0-0","puppeteer":"^0.10.2"},"_id":"@cybernaut/puppeteer@15.0.0-3","scripts":{},"_shasum":"05d14572cd85059cabde3094d1f4ec6da671c563","_from":".","_npmVersion":"3.10.10","_nodeVersion":"8.1.4","_npmUser":{"name":"clebert","email":"clebert@me.com"},"dist":{"shasum":"05d14572cd85059cabde3094d1f4ec6da671c563","tarball":"https://registry.npmjs.org/@cybernaut/puppeteer/-/puppeteer-15.0.0-3.tgz","integrity":"sha512-f1sYD7NN7saQ4YvDuNKfk/5ruDYs4UD0JyrhcC95+grqlbusb+aeiOHxCgsmfyXcKSb5pTUtgj2T/6vUpXZj1w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDuoa37oGX9sDaWAp/dZvQgUQPYF/ZyfCRfUTQjJHLGLAIgJEfQOFzlTdowkXGaoJAu5okQWsz7jwRqFpuZ9G2F2es="}]},"maintainers":[{"name":"clebert","email":"clebert@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/puppeteer-15.0.0-3.tgz_1505163020858_0.2927011891733855"}},"15.0.0-4":{"name":"@cybernaut/puppeteer","version":"15.0.0-4","description":"Convenience functions for using Puppeteer with @cybernaut/test.","license":"MIT","author":{"name":"Clemens Akens","email":"clebert@me.com"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"files":["lib","types"],"dependencies":{"@cybernaut/test":"^15.0.0-4","puppeteer":"^0.10.2"},"_id":"@cybernaut/puppeteer@15.0.0-4","scripts":{},"_shasum":"19631ee3eba29db6a4fe1bc2fa0de1d462166374","_from":".","_npmVersion":"3.10.10","_nodeVersion":"8.1.4","_npmUser":{"name":"clebert","email":"clebert@me.com"},"dist":{"shasum":"19631ee3eba29db6a4fe1bc2fa0de1d462166374","tarball":"https://registry.npmjs.org/@cybernaut/puppeteer/-/puppeteer-15.0.0-4.tgz","integrity":"sha512-wPB7VAdLyepPMk+W8PuryP2nJJURlVKzpWv4o8gCFnLMZDhj/Va6SBmoHB3thx9aDCuHPXwy9BCCoqslLkeMlQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC2IhcHSzS2vILnL8WGn8I2VMuhLzoGYoKkKndKlXuNwgIgTioLpoALfcyKKMhoVKEOKu85Pi/PrAPZ3g5zVExUZgw="}]},"maintainers":[{"name":"clebert","email":"clebert@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/puppeteer-15.0.0-4.tgz_1505167599244_0.09474517637863755"}},"15.0.0-5":{"name":"@cybernaut/puppeteer","version":"15.0.0-5","description":"Convenience functions for using Puppeteer with @cybernaut/test.","license":"MIT","author":{"name":"Clemens Akens","email":"clebert@me.com"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"files":["lib","types"],"dependencies":{"@cybernaut/test":"^15.0.0-4","puppeteer":"^0.10.2"},"_id":"@cybernaut/puppeteer@15.0.0-5","scripts":{},"_shasum":"2e791b126dc554515c7c0fc67f6ee2654c6d8e3b","_from":".","_npmVersion":"3.10.10","_nodeVersion":"8.1.4","_npmUser":{"name":"clebert","email":"clebert@me.com"},"dist":{"shasum":"2e791b126dc554515c7c0fc67f6ee2654c6d8e3b","tarball":"https://registry.npmjs.org/@cybernaut/puppeteer/-/puppeteer-15.0.0-5.tgz","integrity":"sha512-51ogqF8dmm+lp/ON960z+wdd6vIlY0WgE07So6Vjjgqub9l4ugfD8EMxVunwdpefQx2o9M+SN23fZvAfygLdqw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqf0ZoY989XqaNJqcFk8YrCdVcZWwLB8NXF9i8ngyQqwIgVhWhLew5slIvo6FTly075uxl7g19qaf8accj+ifMgiM="}]},"maintainers":[{"name":"clebert","email":"clebert@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/puppeteer-15.0.0-5.tgz_1505201190984_0.585417251335457"}},"15.0.0":{"name":"@cybernaut/puppeteer","version":"15.0.0","description":"Convenience functions for using Puppeteer with @cybernaut/test.","license":"MIT","author":{"name":"Clemens Akens","email":"clebert@me.com"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"files":["lib","types"],"dependencies":{"@cybernaut/test":"^15.0.0","puppeteer":"^0.10.2"},"_id":"@cybernaut/puppeteer@15.0.0","scripts":{},"_shasum":"83f739b406f00f590d87b715ceebcef5200c25ad","_from":".","_npmVersion":"3.10.10","_nodeVersion":"8.1.4","_npmUser":{"name":"clebert","email":"clebert@me.com"},"dist":{"shasum":"83f739b406f00f590d87b715ceebcef5200c25ad","tarball":"https://registry.npmjs.org/@cybernaut/puppeteer/-/puppeteer-15.0.0.tgz","integrity":"sha512-4A4/bNpvASHVaGGbEwIqPyVTiMIE5NVCjrDTYQVCdMboMJKHU6yJoACh83kzmCT1f3yvkZ1JRNavjE0DwBH+Jg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIETFccCbZ44LXrpMP94XOe76k12i8doKZVdDtsViHsMtAiEA2F12qQkduR67B0ILZnKJFmiScgCiTNKYbtNlUhj/lIQ="}]},"maintainers":[{"name":"clebert","email":"clebert@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/puppeteer-15.0.0.tgz_1505671278355_0.05584307131357491"},"deprecated":"Cybernaut is deprecated in favor of pageobject.js.org"},"15.1.0":{"name":"@cybernaut/puppeteer","version":"15.1.0","description":"Convenience functions for using Puppeteer with @cybernaut/test.","license":"MIT","author":{"name":"Clemens Akens","email":"clebert@me.com"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"files":["lib","types"],"dependencies":{"@cybernaut/test":"^15.1.0","puppeteer":"^0.10.2","temp-write":"^3.3.0"},"devDependencies":{"@types/fs-extra":"^4.0.2","fs-extra":"^4.0.2","is-png":"^1.1.0"},"_id":"@cybernaut/puppeteer@15.1.0","scripts":{},"_shasum":"3f8f74b49eafeaa11853ea014dc44ede30c5f860","_from":".","_npmVersion":"3.10.10","_nodeVersion":"8.1.4","_npmUser":{"name":"clebert","email":"clebert@me.com"},"dist":{"shasum":"3f8f74b49eafeaa11853ea014dc44ede30c5f860","tarball":"https://registry.npmjs.org/@cybernaut/puppeteer/-/puppeteer-15.1.0.tgz","integrity":"sha512-N4n6rJ6N1gmIlQI3ktnTdgycpblcPelye3qmHcC36YvpeeNaKw0NHls3mdcGuRXrI5vfrXQ2LpSWmv6k6rL1Tg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICZc3Au5jKU2PQ8GzjYTdAO2rh9LUKEzzlbqgEx4hmLZAiBzZ55FhIq/qoz6+6xUbLCWQ0ezYFzknOjqjwj/xCIldA=="}]},"maintainers":[{"name":"clebert","email":"clebert@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/puppeteer-15.1.0.tgz_1505772129007_0.6565054613165557"},"deprecated":"Cybernaut is deprecated in favor of pageobject.js.org"}},"readme":"# @cybernaut/puppeteer\n\n[![Package Version][badge-npm-image]][badge-npm-link]\n[![Build Status][badge-travis-image]][badge-travis-link]\n[![Coverage Status][badge-coveralls-image]][badge-coveralls-link]\n\n> Convenience functions for using [Puppeteer][external-puppeteer] with [`@cybernaut/test`][package-test].\n\n## Installation\n\n```sh\nnpm install @cybernaut/puppeteer\n```\n\n## Examples (using [Jest][external-jest])\n\n**Tip 💡** [Jest][external-jest] allows the parallel execution of multiple test files using the [`--maxWorkers` CLI option][external-jest-maxworkers].\nFor this reason, a file should always contain only one test.\nThus, the execution speed of your entire test suite can be increased massively.\n\n### Navigating to [https://example.com][external-example] and asserting the page title\n\n```js\nconst {\n  createTestSetup,\n  createTestTeardown\n} = require('@cybernaut/puppeteer/lib/TestContext');\n\nconst {createTestRunner} = require('@cybernaut/test/lib/TestRunner');\n\n/* Automated Web UI tests usually run much longer than unit tests,\n * so the default timeout should be adjusted accordingly.\n */\njasmine.DEFAULT_TIMEOUT_INTERVAL = 30 * 1000; /* 30 seconds */\n\nconst run = createTestRunner(createTestSetup(), createTestTeardown());\n\ntest(\n  'Navigating to https://example.com and asserting the page title',\n  run(({page}) => [\n    async () => page.goto('https://example.com'),\n    async () => expect(page.title()).resolves.toBe('Example Domain')\n  ])\n);\n```\n\n### Sign in to a fictitious \"My Account\" page\n\n**Tip 💡** A single test step should include only one user action.\nIf such a test step fails, then it can be repeated without side effects.\n\n#### Bad example ❌\n\n```js\ntest(\n  'Sign in to a fictitious \"My Account\" page',\n  run(({page}) => [\n    async () => {\n      await page.goto('https://example.com');\n\n      await expect(page.title()).resolves.toBe('Sign In');\n\n      await page.focus('input#username');\n      await page.type('username@example.com', {delay: 100});\n\n      await page.focus('input#password');\n      await page.type('123456', {delay: 100});\n\n      await page.click('button#submit-button');\n\n      await expect(page.title()).resolves.toBe('My Account');\n    }\n  ])\n);\n```\n\n#### Good example ✅\n\n```js\ntest(\n  'Sign in to a fictitious \"My Account\" page',\n  run(({page}) => [\n    async () => page.goto('https://example.com'),\n    async () => expect(page.title()).resolves.toBe('Sign In'),\n    async () => page.focus('input#username'),\n    async () => page.type('username@example.com', {delay: 100}),\n    async () => page.focus('input#password'),\n    async () => page.type('123456', {delay: 100}),\n    async () => page.click('button#submit-button'),\n    async () => expect(page.title()).resolves.toBe('My Account')\n  ])\n);\n```\n\n### Taking an environment-dependent screenshot\n\n`@cybernaut/puppeteer` provides an environment-dependent screenshot function.\nOn the CI the screenshot is output as Base64-encoded PNG, locally as PNG file.\n\n**Tip 💡** The Base64-encoded PNG can be visualized by any Online Base64 Image Decoder.\n\n```js\nconst {takeScreenshot} = require('@cybernaut/puppeteer/lib/takeScreenshot');\n\ntest(\n  'Taking an environment-dependent screenshot',\n  run(({page}) => [\n    async () => page.goto('https://example.com'),\n    async () => console.info('Screenshot:', await takeScreenshot(page))\n  ])\n);\n```\n\n#### Output (`process.env.CI === 'true'`)\n\n```sh\nScreenshot: iVBORw0KGgoAAAANSUhEUgAAAyAAAAJYCAYAAACadoJwAAA...\n```\n\n#### Output (`process.env.CI !== 'true'`)\n\n```sh\nScreenshot: /private/var/folders/dd/5ynm3wcj1y3dsdkzx13d_8qm0000gn/T/92254da8-6df6-4ae2-aae2-29b68fe0f3a4/screenshot.png\n```\n\n## Type definitions\n\nBecause of the lack of publicly available [TypeScript][external-typescript] type definitions for [Puppeteer][external-puppeteer], this package provides its own.\n\n**Attention ⚠️** The [TypeScript][external-typescript] type definitions for [Puppeteer][external-puppeteer] are [not yet complete][issue-391].\n\n### @cybernaut/puppeteer/lib/TestContext\n\n```ts\nimport {TestSetup, TestTeardown} from '@cybernaut/test/lib/TestRunner';\nimport {Browser, LaunchOptions, Page} from 'puppeteer';\n\nexport interface TestContext {\n  readonly browser: Browser;\n  readonly page: Page;\n}\n\nexport declare function createTestSetup(\n  launchOptions?: LaunchOptions\n): TestSetup<TestContext>;\n\nexport declare function createTestTeardown(): TestTeardown<TestContext>;\n```\n\n### @cybernaut/puppeteer/lib/takeScreenshot\n\n```ts\nimport {Page} from 'puppeteer';\n\nexport declare function takeScreenshot(page: Page): Promise<string>;\n```\n\n---\nBuilt by (c) Clemens Akens. Released under the terms of the [MIT License][cybernaut-license].\n\n[badge-npm-image]: https://img.shields.io/npm/v/@cybernaut/puppeteer.svg\n[badge-npm-link]: https://www.npmjs.com/package/@cybernaut/puppeteer\n[badge-travis-image]: https://travis-ci.org/clebert/cybernaut.svg?branch=master\n[badge-travis-link]: https://travis-ci.org/clebert/cybernaut\n[badge-coveralls-image]: https://coveralls.io/repos/github/clebert/cybernaut/badge.svg?branch=master\n[badge-coveralls-link]: https://coveralls.io/github/clebert/cybernaut?branch=master\n\n[cybernaut-license]: https://github.com/clebert/cybernaut/blob/master/LICENSE\n\n[package-test]: https://github.com/clebert/cybernaut/tree/master/@cybernaut/test\n\n[issue-391]: https://github.com/clebert/cybernaut/issues/391\n\n[external-example]: https://example.com\n[external-jest]: https://facebook.github.io/jest/\n[external-jest-maxworkers]: https://facebook.github.io/jest/docs/en/cli.html#maxworkers-num\n[external-puppeteer]: https://github.com/GoogleChrome/puppeteer\n[external-typescript]: http://www.typescriptlang.org/\n","maintainers":[{"name":"clebert","email":"clebert@me.com"}],"time":{"modified":"2022-06-12T16:50:33.296Z","created":"2017-09-11T10:08:02.692Z","15.0.0-0":"2017-09-11T10:08:02.692Z","15.0.0-1":"2017-09-11T19:39:38.614Z","15.0.0-2":"2017-09-11T19:55:15.085Z","15.0.0-3":"2017-09-11T20:50:21.825Z","15.0.0-4":"2017-09-11T22:06:40.070Z","15.0.0-5":"2017-09-12T07:26:31.891Z","15.0.0":"2017-09-17T18:01:19.334Z","15.1.0":"2017-09-18T22:02:09.899Z"},"homepage":"https://cybernaut.js.org/","repository":{"type":"git","url":"git+https://github.com/clebert/cybernaut.git"},"author":{"name":"Clemens Akens","email":"clebert@me.com"},"bugs":{"url":"https://github.com/clebert/cybernaut/issues"},"license":"MIT","readmeFilename":"README.md"}