Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/circleci/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2.1
orbs:
node: circleci/node@5.0.2
node: circleci/node@7.2.1

jobs:
upload_screenshots:
Expand Down
5 changes: 3 additions & 2 deletions examples/circleci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ This example showcases Argos Visual Testing running on [CircleCI](https://circle

## Setup

- Follow [Argos getting started guide](https://argos-ci.com/docs) to obtain a Argos token.
- Add `ARGOS_TOKEN` as an [masked environment variable on CircleCI](https://circleci.com/docs/env-vars)
- [Create a project in Argos](https://app.argos-ci.com/new) and copy its [project token](https://argos-ci.com/docs/learn/account-and-access/project-tokens).
- Add it as an `ARGOS_TOKEN` [environment variable on CircleCI](https://circleci.com/docs/env-vars) (values are masked in the job output).
- Replace the placeholder comment in `.circleci/config.yml` with the steps that save your screenshots to `./screenshots`.

## Links

Expand Down
15 changes: 12 additions & 3 deletions examples/cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,24 @@

# Example of Argos + Cypress

This example showcases Argos Visual Testing integrated to [Cypress](https://www.cypress.io/) testing framework.
This example showcases Argos Visual Testing integrated with the [Cypress](https://www.cypress.io/) testing framework.

## Run the example

```sh
npm install
npm test
```

`cy.argosScreenshot` writes the screenshots to `cypress/screenshots`. The Argos task in `cypress.config.js` uploads them to Argos only when the tests run on CI, using the `ARGOS_TOKEN` environment variable.

## Integrate with CI

This example only shows how to takes screenshots using Argos + Cypress.
This example only shows how to take screenshots using Argos + Cypress.

It does not include any CI integration on purpose to keep it as clear as possible.

Read [Argos documentations](https://argos-ci.com/docs) or explore [examples](https://github.com/argos-ci/argos/tree/main/examples) to find the best way to integrate your CI.
Read the [Cypress quickstart](https://argos-ci.com/docs/quickstart/cypress-quickstart) or explore the [examples](https://github.com/argos-ci/argos-javascript/tree/main/examples) to find the best way to integrate your CI.

## Links

Expand Down
9 changes: 4 additions & 5 deletions examples/cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const { defineConfig } = require("cypress");
const { registerArgosTask } = require("@argos-ci/cypress/task");

module.exports = defineConfig({
// setupNodeEvents can also be defined in "component"
e2e: {
setupNodeEvents(on, config) {
require("@argos-ci/cypress/task")(on, config, {
// Enable upload to Argos only when it runs on CI.
async setupNodeEvents(on, config) {
registerArgosTask(on, config, {
// Upload to Argos on CI only.
uploadToArgos: !!process.env.CI,
// Set your Argos token (required only if you don't use GitHub Actions).
token: "<YOUR-ARGOS-TOKEN>",
});

// include any other plugin code...
Expand Down
8 changes: 4 additions & 4 deletions examples/cypress/cypress/e2e/1-getting-started/todo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

// This spec file is an extract of the first example generated by Cypress.
//
// We have added the `cy.argosSnapshot` command
// introduced by @argos/cypress package to take screenshots.
// We have added the `cy.argosScreenshot` command
// provided by the @argos-ci/cypress package to take screenshots.

describe("example to-do app", () => {
beforeEach(() => {
Expand All @@ -17,7 +17,7 @@ describe("example to-do app", () => {
cy.get(".todo-list li").first().should("have.text", "Pay electric bill");
cy.get(".todo-list li").last().should("have.text", "Walk the dog");

// 👇 That's how we take screenshot
// 👇 That's how we take a screenshot
cy.argosScreenshot("with two items");
});

Expand All @@ -29,7 +29,7 @@ describe("example to-do app", () => {
.last()
.should("have.text", newItem);

//👇 Here, an other screenshot will be taken
// 👇 Here, another screenshot is taken
cy.argosScreenshot("with an added item");
});
});
17 changes: 2 additions & 15 deletions examples/cypress/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Add support of `argosScreenshot` command
// This file is loaded automatically before your test files.
// Add the `cy.argosScreenshot` command.
import "@argos-ci/cypress/support";
1 change: 1 addition & 0 deletions examples/cypress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"private": true,
"scripts": {
"test": "cypress run",
"cypress:open": "cypress open"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions examples/github-actions/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:

steps:
- name: Check out repository code
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v7
with:
node-version: current
node-version: lts/*

- name: Install dependencies
run: npm ci
Expand Down
5 changes: 3 additions & 2 deletions examples/github-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ This example showcases Argos Visual Testing running on [GitHub Actions](https://

## Setup

- Follow [Argos getting started guide](https://argos-ci.com/docs) to obtain a Argos token.
- Add `ARGOS_TOKEN` as a [GitHub Actions Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets)
- [Create a project in Argos](https://app.argos-ci.com/new) and copy its [project token](https://argos-ci.com/docs/learn/account-and-access/project-tokens).
- Add it as an `ARGOS_TOKEN` [GitHub Actions secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets).
- Replace the placeholder comment in `.github/workflows/ci.yml` with the steps that save your screenshots to `./screenshots`.

## Links

Expand Down
3 changes: 0 additions & 3 deletions examples/nextjs/.eslintrc.json

This file was deleted.

17 changes: 14 additions & 3 deletions examples/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@

# Example of Argos + Next.js

This example showcases Argos Visual Testing integrated to [Next.js](https://nextjs.org/).
This example showcases Argos Visual Testing integrated to a [Next.js](https://nextjs.org/) app, using [Playwright](https://playwright.dev/) and the [Argos Playwright SDK](https://argos-ci.com/docs/quickstart/playwright-quickstart).

## Run locally

```sh
npm install
npx playwright install
npm run build
npx playwright test
```

Playwright starts the built app with `npm run start` (see `webServer` in `playwright.config.ts`) and runs the tests in Chromium, Firefox and WebKit. Locally, the Argos screenshots are written to `test-results/` and nothing is uploaded: the Argos reporter uploads to Argos on CI only.

## Integrate with CI

This example shows how configure GitHub Actions to run Playwright on your CI.
Run `npm run build` and `npx playwright test` on your CI with the `ARGOS_TOKEN` environment variable set. The [Playwright quickstart](https://argos-ci.com/docs/quickstart/playwright-quickstart) shows a GitHub Actions workflow.

Read [Argos documentations](https://argos-ci.com/docs) or explore [examples](https://github.com/argos-ci/argos/tree/main/examples) to find the best way to integrate your CI.
Read the [Argos documentation](https://argos-ci.com/docs) or explore [examples](https://github.com/argos-ci/argos-javascript/tree/main/examples) to find the best way to integrate your CI.

## Links

Expand Down
4 changes: 0 additions & 4 deletions examples/nextjs/next.config.js

This file was deleted.

7 changes: 7 additions & 0 deletions examples/nextjs/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
28 changes: 12 additions & 16 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"start": "next start"
},
"dependencies": {
"next": "14.1.4",
"react": "^18",
"react-dom": "^18"
"next": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@argos-ci/playwright": "^2.0.0",
"@playwright/test": "^1.42.1",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.4.19",
"eslint": "^8",
"eslint-config-next": "14.1.4",
"postcss": "^8",
"tailwindcss": "^3.4.3",
"typescript": "^5"
"@argos-ci/playwright": "latest",
"@playwright/test": "latest",
"@tailwindcss/postcss": "latest",
"@types/node": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"tailwindcss": "latest",
"typescript": "latest"
}
}
81 changes: 36 additions & 45 deletions examples/nextjs/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
import { createArgosReporterOptions } from "@argos-ci/playwright/reporter";

/**
* See https://playwright.dev/docs/test-configuration.
Expand All @@ -19,62 +14,58 @@ export default defineConfig({
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
// Adds Argos reporter in CI environments
reporter: process.env.CI
? [["list"], ["@argos-ci/playwright/reporter"]]
: "list",

reporter: [
// Use "dot" reporter on CI, "list" otherwise (Playwright default).
process.env.CI ? ["dot"] : ["list"],
// Add Argos reporter.
[
"@argos-ci/playwright/reporter",
createArgosReporterOptions({
// Upload to Argos on CI only.
uploadToArgos: !!process.env.CI,
}),
],
],

// Start the production build of the app before the tests run.
// Run `npm run build` first.
webServer: {
command: "npm run start",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
},

use: {
// Capture a screenshot when a test fails
screenshot: "only-on-failure",
// Resolve relative URLs like page.goto("/") against the app.
baseURL: "http://localhost:3000",

// Keeps traces for failed tests
trace: "retain-on-failure",
// Collect trace when retrying the failed test.
trace: "on-first-retry",

// Capture screenshot after each test failure.
screenshot: "only-on-failure",
},

/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
use: {
...devices["Desktop Chrome"],
// Reduce text rendering differences between machines.
launchOptions: {
args: ["--disable-lcd-text", "--font-render-hinting=none"],
},
},
},

{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},

{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
webServer: {
command: "pnpm run dev",
url: "http://127.0.0.1:3000",
reuseExistingServer: !process.env.CI,
},
});
6 changes: 0 additions & 6 deletions examples/nextjs/postcss.config.js

This file was deleted.

7 changes: 7 additions & 0 deletions examples/nextjs/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};

export default config;
2 changes: 1 addition & 1 deletion examples/nextjs/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading