Skip to content

chore: adds cypress component tests #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 6, 2025
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
10 changes: 9 additions & 1 deletion .github/workflows/check_fullstack_demo_ts_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ jobs:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
run: |
npm ci
npm run test
npm run test

- name: Run Cypress component tests
uses: cypress-io/github-action@v6
env:
NEXT_PUBLIC_API_URL: http://localhost:8080
with:
working-directory: ./lib/javascript/fullstack_demo
component: true
6 changes: 5 additions & 1 deletion lib/javascript/fullstack_demo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ yarn-error.log*
next-env.d.ts

# database
db.json
db.json

# Cypress
/cypress/snapshots/actual
/cypress/snapshots/diff
18 changes: 18 additions & 0 deletions lib/javascript/fullstack_demo/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from 'cypress';
import { configureVisualRegression } from 'cypress-visual-regression';

export default defineConfig({
component: {
devServer: {
framework: 'next',
bundler: 'webpack',
},
env: {
visualRegressionType: 'regression',
},
screenshotsFolder: './cypress/snapshots/actual',
setupNodeEvents(on, config) {
configureVisualRegression(on);
},
},
});
5 changes: 5 additions & 0 deletions lib/javascript/fullstack_demo/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/javascript/fullstack_demo/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { addCompareSnapshotCommand } from 'cypress-visual-regression/dist/command';
addCompareSnapshotCommand();
14 changes: 14 additions & 0 deletions lib/javascript/fullstack_demo/cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
<!-- Used by Next.js to inject CSS. -->
<div id="__next_css__DO_NOT_USE__"></div>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
37 changes: 37 additions & 0 deletions lib/javascript/fullstack_demo/cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ***********************************************************
// This example support/component.ts 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
// ***********************************************************

// Import commands.js using ES2015 syntax:
import '../../src/app/globals.css';
import './commands';

import { mount } from 'cypress/react';

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount;
}
}
}

Cypress.Commands.add('mount', mount);

// Example use:
// cy.mount(<MyComponent />)
8 changes: 8 additions & 0 deletions lib/javascript/fullstack_demo/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ts-node": {
"transpileOnly": true,
"compilerOptions": {
"module": "ES2015"
}
}
}
8 changes: 8 additions & 0 deletions lib/javascript/fullstack_demo/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @ts-check

/** @type {import('next').NextConfig} */
const nextConfig = {
/* config options here */
};

export default nextConfig;
7 changes: 0 additions & 7 deletions lib/javascript/fullstack_demo/next.config.ts

This file was deleted.

Loading
Loading