Skip to content

Instantly share code, notes, and snippets.

View abhinaba-ghosh's full-sized avatar

Abhinaba Ghosh abhinaba-ghosh

View GitHub Profile
describe('protractor react selector tests', () => {
beforeAll(async function () {
await browser.waitForAngularEnabled(false)
await browser.get('https://ahfarmer.github.io/calculator/')
await browser.waitForReact()
})
it('This should test react selector with component, props and react root element', async () => {
// state is empty for the element
const _element = element(by.react('t', { name: '5' }, {}, '#root'))
beforeAll(() => {
await browser.get('http://localhost:3000/myApp')
await browser.waitForReact()
})
// imports
const MyComponent = ({ someBooleanProp }) => (
<div>My Component {someBooleanProp ? 'show this' : ''} </div>
);
const App = () => (
<div>
<MyComponent />
<MyComponent someBooleanProp={true} />
</div>
);
// first option: TAG your scenario uniquely and use the tag to execute a particular scenario
npx protractor protractor.conf.js --cucumberOpts.tags="@tag1"
// second option: Use the name of the scenario
npx protractor protractor.conf.js --cucumberOpts.name="my scenario name"
// Specify a feature file
$ cucumber-js features/my_feature.feature
// Specify a scenario by its line number
$ cucumber-js features/my_feature.feature:3
// Specify a scenario by its name matching a regular expression
$ cucumber-js --name "topic 1"
import "jasmine";
import { browser } from "protractor";
import { lrHelper } from "./lighthouse/lighthouse.helper";
describe("Open Angular Docs and run a lighthouse scan", () => {
beforeEach(async () => {
await browser.waitForAngularEnabled(false);
await browser.get("https://angular.io/");
});
@abhinaba-ghosh
abhinaba-ghosh / lighthouse.helper.ts
Created November 11, 2019 18:54
Lighthouse Protractor Helper Methods
import lighthouse = require("lighthouse");
import ReportGenerator = require("lighthouse/lighthouse-core/report/report-generator");
import * as lightExpect from "./lighthouse.expectation.json";
import * as fs from "fs";
export class LightHouseHelper {
// method to run lighthouse audit
lighthouseAudit = async url => {
console.log("target url:", url);
const opts = {
@abhinaba-ghosh
abhinaba-ghosh / conf.ts
Created November 11, 2019 18:48
Protractor Lighthouse Configuration file
import { Config } from "protractor";
export let config: Config = {
specs: ["./specs/test.js"],
framework: "jasmine",
capabilities: {
browserName: "chrome",
chromeOptions: {
useAutomationExtension: false,
@abhinaba-ghosh
abhinaba-ghosh / package.json
Created November 11, 2019 18:37
Lighthouse Protractor Package.json
{
"name": "protractor-lighthouse",
"version": "1.0.0",
"description": "Demo project to shocase Protractor integration with lighthouse",
"main": "index.js",
"dependencies": {
"@types/jasmine": "^2.8.6",
"@types/node": "^9.4.6",
"jasmine": "^3.1.0",
"lighthouse": "5.5.0",