-
Notifications
You must be signed in to change notification settings - Fork 112
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
Cypress setup #2221
Open
scottrosen14
wants to merge
1
commit into
PolicyEngine:master
Choose a base branch
from
scottrosen14:cypress-setup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,627
−46
Open
Cypress setup #2221
Changes from all commits
Commits
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
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,34 @@ | ||
/build/** | ||
/src/__tests__/__setup__/data.json | ||
# Build outputs | ||
build/ | ||
dist/ | ||
out/ | ||
.next/ | ||
coverage/ | ||
|
||
# Dependencies | ||
node_modules/ | ||
**/node_modules/ | ||
|
||
# Config files | ||
*.config.js | ||
|
||
# Public assets | ||
public/ | ||
|
||
# Cache | ||
.cache/ | ||
.eslintcache | ||
|
||
# Environment files | ||
.env* | ||
!.env.example | ||
|
||
# Test files (optional, depending on your needs) | ||
/src/__tests__/__setup__/data.json | ||
# **/*.test.js | ||
# **/*.spec.js | ||
# **/*.cy.js | ||
|
||
# Generated files | ||
*.min.js | ||
*.bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,46 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# Production | ||
build/ | ||
dist/ | ||
out/ | ||
.next/ | ||
coverage/ | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
node_modules/ | ||
.pnp | ||
.pnp.js | ||
|
||
## vscode settings | ||
/.vscode | ||
# IDE settings | ||
.vscode/ | ||
.idea/ | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
coverage/ | ||
cypress/screenshots | ||
cypress/videos | ||
cypress/downloads | ||
src/__tests__/__setup__/data.json | ||
|
||
# Cache and logs | ||
.cache/ | ||
*.log | ||
logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
/.gcloudignore | ||
/app.yaml | ||
/main.py | ||
/requirements.txt | ||
.pnpm-debug.log* | ||
.eslintcache | ||
.stylelintcache | ||
**/__pycache__ | ||
.env | ||
/src/__tests__/__setup__/data.json | ||
.idea | ||
|
||
venv/* | ||
# environment variables | ||
.env* | ||
|
||
# Misc | ||
.DS_Store | ||
.gcloudignore | ||
app.yaml | ||
main.py | ||
requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
{} | ||
{ | ||
"semi": true, | ||
"trailingComma": "es5", | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": false, | ||
"jsxSingleQuote": false, | ||
"arrowParens": "avoid", | ||
"endOfLine": "auto", | ||
"bracketSameLine": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { defineConfig } = require("cypress"); | ||
require("dotenv").config({ | ||
path: `.env.${process.env.STAGE_ENV || "development"}`, | ||
}); | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
baseUrl: process.env.REACT_APP_POLICYENGINE_DOMAIN, | ||
supportFile: "cypress/support/e2e.js", | ||
specPattern: "cypress/tests/**/*.cy.js", | ||
}, | ||
setupNodeEvents(on, config) { | ||
on("task", { | ||
log(message) { | ||
console.log(message); | ||
return null; | ||
}, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************** | ||
// This example commands.ts shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
// | ||
// declare global { | ||
// namespace Cypress { | ||
// interface Chainable { | ||
// login(email: string, password: string): Chainable<void> | ||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.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 "./commands"; | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { checkCountryRedirect } from "../../utils/checkCountryRedirect"; | ||
|
||
describe("PolicyEngine Homepage", () => { | ||
const regexArg = /the\s(us|u\.s\.|usa|united states)/; | ||
|
||
beforeEach(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I run these tests locally, none of the tests actually run, as I get this error here:
I admit, it may be my setup, as I'm unfamiliar with Cypress, but wanted to highlight this. |
||
cy.visit("/"); | ||
}); | ||
|
||
afterEach(() => { | ||
Object.defineProperty(window.navigator, "language", { | ||
value: window.navigator.language, | ||
configurable: true, | ||
}); | ||
}); | ||
|
||
it("should redirect from root to US homepage by default", () => { | ||
Object.defineProperty(window.navigator, "language", { | ||
value: "", | ||
configurable: true, | ||
}); | ||
checkCountryRedirect("us", regexArg); | ||
}); | ||
|
||
it("should redirect from root to US homepage if browser language is en-US", () => { | ||
Object.defineProperty(window.navigator, "language", { | ||
value: "en-US", | ||
configurable: true, | ||
}); | ||
checkCountryRedirect("us", regexArg); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const checkCountryRedirect = (country, regexArg = "") => { | ||
cy.location("pathname").should((loc) => { | ||
const path = loc.split("/"); | ||
expect(path[1]).to.equal(country); | ||
}); | ||
|
||
cy.get("#home-used-by").then(($ele) => { | ||
const text = $ele.text()?.toLowerCase(); | ||
const regex = new RegExp(regexArg, "i"); | ||
expect(regex.test(text)).to.equal(true); | ||
}); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why you enabled these lint rules. Was this a file that wasn't meant to be merged? Do you feel these would be the best for our linting structure? Or is this personal preference?