Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
994731b
feat: add browser logs
vCaisim Mar 27, 2023
9fdeac5
chore: move from next to react + vite + typescript
vCaisim Mar 28, 2023
1951fcf
feat: add callback option
vCaisim Mar 28, 2023
ca38391
feat: add logs from the Console api
vCaisim Mar 28, 2023
8061f7c
fix: use useSearchParams to get the payload query param
vCaisim Mar 29, 2023
8cbb7e7
fix: clear the payload query param when the payload is removed
vCaisim Mar 29, 2023
fd69bf4
fix: reset the state when the payload param is removed
vCaisim Mar 29, 2023
9aeefe9
feat: update the UI for console messages
vCaisim Mar 29, 2023
b039b88
fix: get the correct values from the Console browser api
vCaisim Mar 29, 2023
de93226
chore: do not use logs from the deprecated Console domain
vCaisim Mar 30, 2023
dacd451
chore: limit the connection retries to the Chrome Debugging Protocol
vCaisim Mar 30, 2023
e512b06
fix: handle electron
vCaisim Mar 31, 2023
599a295
chore: small ui update
vCaisim Apr 3, 2023
601a8ac
chore: mini refactor
vCaisim Apr 3, 2023
540573d
chore: reconnect to cdp before each spec
vCaisim Apr 3, 2023
c062d23
chore: remove docs and ui packages
vCaisim Apr 3, 2023
428f8b0
chore: remove logs and comments
agoldis Apr 5, 2023
a861f77
fix: move the chrome-remote-interface dependences to the plugin package
vCaisim Apr 5, 2023
a728799
chore: import the types from cypress-debugger
vCaisim Apr 5, 2023
8e10453
fix: comments
vCaisim Apr 5, 2023
5eb5578
feat: add PluginOptions type
vCaisim Apr 5, 2023
67c8b7e
update README
vCaisim Apr 5, 2023
d3d1e05
fix: return rdp port depending on browser
vCaisim Apr 5, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,72 @@ npm install
npx cypress run --browser chrome
```

You will see new `json` files created in `apps/web/dump`. Each file contains fields: `cy`, `rr`, and `har`.
The plugin generates a `json` file for each test into `apps/web/dump`. Each file contains the following information about a specific test:

- `cy` - data from cypress events
- `rr` - data from the [rrweb](https://www.npmjs.com/package/rrweb)
- `har` - data from the [HttpArchive Generator](https://github.com/NeuraLegion/cypress-har-generator)
- `cy` - a list of cypress events. The data is taken from the cypress `log:added` event, and pushed into an array, emptied at the `afterEach` hook.

Run the local server at http://localhost:3000/ and upload some file from `apps/web/dump` using the UI.
- `rr` - a list of [rrweb](https://www.npmjs.com/package/rrweb) entries, which represents the browser state at a moment in time. The entries are linked to `cy` events on cypress `log:added` and `log:changed` events.

- `har` - network history recorded by the [HttpArchive Generator](https://github.com/NeuraLegion/cypress-har-generator). The recording is started at `beforeEach` hook, and stopped at `afterEach`. The data is saved in a temporary folder then read, and moved to the result file.

- `meta` - an object which contains the following test data:
```typescript
{
spec: string; // spec filename
test: string[]; // test title
retryAttempt: number; // https://docs.cypress.io/guides/guides/test-retries
}
```

- `browserLogs` - the browser logs at a moment in time. The data by connecting to the browser using [chrome-remote-interface](https://www.npmjs.com/package/chrome-remote-interface), a [Chrome Debugging Protocol](https://chromedevtools.github.io/devtools-protocol/) interface. The Chrome Debugging Protocol is connecting to the browser at `before:browser:launch` event.

- `pluginMeta` - an object containing the data passed down to the `meta` field of the install optional, second parameter:
```js
// cypress.config.js

setupNodeEvents(on, config) {
require("@currents/cypress-debugger").install(on, {
// pluginMeta
meta: {
key: "value",
},
});

return config;
})
```

Run the local server at http://localhost:3000/ and upload some files from `apps/web/dump` using the UI.

### Notes

A `har.json` file could be visualized with [this tool](https://toolbox.googleapps.com/apps/har_analyzer/)

The [HAR generator](https://github.com/NeuraLegion/cypress-har-generator), currently, only supports Chrome family browsers. Please refer to [this](https://github.com/NeuraLegion/cypress-har-generator#generating-a-har-file) section in order to run cypress for other browsers.

To obtain a result containing `browserLogs` run `npx cypress run --browser chrome --spec ./cypress/e2e/local.spec.js`

## Usage

- call the `install` function inside the `setupNodeEvents` in the cypress config file:

The function takes the cypress events as the first parameter, and an optional object as the second parameter.

Available options:
- `meta` - the field is passed down to every generated file.
- `callback` - a function that executes after each test having the generated data as a parameter.

```typescript
const { defineConfig } = require("cypress");
const { install } = require("@currents/cypress-debugger");

const options: { meta?: any; callback?: Function } = {}

module.exports = defineConfig({
e2e: {
...
setupNodeEvents(on, config) {
install(on, config);
require("@currents/cypress-debugger").install(on, options);

return config;
},
},
Expand Down
24 changes: 24 additions & 0 deletions apps/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
30 changes: 0 additions & 30 deletions apps/web/README.md

This file was deleted.

75 changes: 0 additions & 75 deletions apps/web/components/CySteps/CyStepItem.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions apps/web/components/CySteps/CySteps.module.scss

This file was deleted.

28 changes: 0 additions & 28 deletions apps/web/components/CySteps/CySteps.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions apps/web/components/Metadata/Metadata.module.scss

This file was deleted.

11 changes: 0 additions & 11 deletions apps/web/components/Metadata/Metadata.tsx

This file was deleted.

60 changes: 0 additions & 60 deletions apps/web/context/cypressSteps.tsx

This file was deleted.

11 changes: 9 additions & 2 deletions apps/web/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
const { defineConfig } = require("cypress");
const { install } = require("@currents/cypress-debugger");

module.exports = defineConfig({
e2e: {
baseUrl: "https://todomvc.com/examples/backbone",
specPattern: "cypress/e2e/*.spec.js",
supportFile: "cypress/support/e2e.ts",
setupNodeEvents(on, config) {
install(on, config);
require("@currents/cypress-debugger").install(on, {
meta: {
key: "value",
},
callback: (val) => {
// executed after each test
},
});

return config;
},
},
Expand Down
11 changes: 11 additions & 0 deletions apps/web/cypress/e2e/local.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
context("Check for console output", function () {
it("should display the correct text", function () {
cy.origin("http://localhost:3000", () => {
cy.visit("/");
cy.get("label").should(
"contain",
"To upload data - click on the text or drag a file into the area"
);
});
});
});
13 changes: 13 additions & 0 deletions apps/web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Web</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
5 changes: 0 additions & 5 deletions apps/web/next-env.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions apps/web/next.config.js

This file was deleted.

Loading