Skip to content
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

initial cypress test for nav img #4

Open
wants to merge 3 commits into
base: move-to-svelte
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ yarn preview
- [x] Mobile optimization
- [x] Edge runtime

## Testing
## Cypress Testing
To run the tests use the following command
`npx cypress run`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add that the user needs to have the server running first with yarn preview?


You may find the spec tests under `cypress/e2e/*.cy.ts`. You may add additional tests to the existing file or start a new file in the same directory. Files in the `cypress/e2e` directory will automatically be picked up.
15 changes: 15 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'cypress'

// example EVN vars can use in spec like the following:
// cy.visit(Cypress.env('proto')+'://'+Cypress.env('host')+'/');`
export default defineConfig({
projectId: 'ENF EVM Faucet',
e2e: {
baseUrl: 'http://localhost:4173',
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this port be 5173 as the default svelte port?

//env: {
// proto: 'http',
// host: '10.10.10.1:4173',
//},
video: false,
})
6 changes: 6 additions & 0 deletions cypress/e2e/base_page_check.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('Base Page', () => {
it('navigation has image', () => {
cy.visit('/');
cy.get('nav').find('img').should('have.attr', 'src', '/eos-evm.svg');
});
});
5 changes: 5 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Example of a custom command
Cypress.Commands.add('dataCy', (value) => {
return cy.get(`[data-cy=${value}]`)
});

15 changes: 15 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import './commands'

// <reference types="cypress" />

declare global {
namespace Cypress {
interface Chainable {
/**
* Custom command to select DOM element by data-cy attribute.
* @example cy.dataCy('greeting')
*/
dataCy(value: string): Chainable<Element>;
}
}
}
8 changes: 8 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es6",
"lib": ["es6", "dom"],
"types": ["cypress", "node"]
},
"include": ["**/*.ts"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@wharfkit/session": "latest",
"@wharfkit/wallet-plugin-privatekey": "latest",
"autoprefixer": "^10.4.7",
"cypress": "^12.11.0",
"cypress": "^12.14.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason we bumped the cypress version?

"dayjs": "1.x",
"dotenv": "^16.0.3",
"eslint": "^8.28.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ cssesc@^3.0.0:
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee"
integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==

cypress@^12.11.0:
cypress@^12.14.0:
version "12.14.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.14.0.tgz#37a19b85f5e9d881995e9fee1ddf41b3d3a623dd"
integrity sha512-HiLIXKXZaIT1RT7sw1sVPt+qKtis3uYNm6KwC4qoYjabwLKaqZlyS/P+uVvvlBNcHIwL/BC6nQZajpbUd7hOgQ==
Expand Down