Skip to content
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
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["istanbul"]
}
2 changes: 2 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
VITE_API_KEY=your_api_key_here
VITE_BASE_URL=https://api.unsplash.com
VITEST=false
SERVER_PORT=3033
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ dist-ssr
*.njsprojc
*.sln
*.sw?

# Local Netlify folder
.netlify

.nyc_output

instrumented
17 changes: 17 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"all": true,
"extends": "@istanbuljs/nyc-config-typescript",
"check-coverage": true,
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": [
"cypress/**/*.*",
"**/*.d.ts",
"**/*.cy.tsx",
"**/*.cy.ts",
"**/*.test.tsx",
"**/*.test.ts",
"**/setup.ts",
"src/data/**/*.*",
"src/mocks/**/*.*"
]
}
19 changes: 19 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'cypress';
import cyCoverageTask from '@cypress/code-coverage/task';

export default defineConfig({
env: {
codeCoverage: {
exclude: 'cypress/**/*.*',
instrumentation: false,
},
},
e2e: {
baseUrl: 'http://localhost:3001',
setupNodeEvents(on, config) {
cyCoverageTask(on, config);
return config;
},
video: false,
},
});
59 changes: 59 additions & 0 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
describe('RS React app E2E', () => {
it('should have About page', () => {
cy.visit('/about');

cy.get('h1')
.contains(/About us/i)
.should('be.visible');
});

it('should have Forms page', () => {
cy.visit('/forms');

cy.get('#userName').should('have.value', '');
cy.get('#userSurname').should('have.value', '');
cy.get('#userSurname').should('have.value', '');
cy.get('#userBirthday').should('have.value', '');
cy.get('button').should('have.text', 'Submit');
cy.get('button').contains('Submit').click();
cy.get('p.text-red-500').should('have.length', 7);

cy.get('#userName').type('Name').should('have.value', 'Name');
cy.get('#userSurname').type('Surame').should('have.value', 'Surame');

cy.get('#userGender-male').click().should('have.checked');
cy.get('#userGender-female').click().should('have.checked');
cy.get('#userTerms').click().should('have.checked');
cy.get('#userPromotions').click().should('have.checked');
});

it('should have 404 page', () => {
cy.visit('/notfound');

cy.get('h1')
.contains(/NotFound/i)
.should('be.visible');
});

it('should have home page with initial images', () => {
cy.visit('/');

cy.get('#search').should('have.value', '');

cy.get('img').should('have.length', 10);

cy.get('div > img').first().click();
});

it('should have home page with no images after applying unhandled search string', () => {
cy.visit('/');
cy.get('input').type('qwertyuiopijn').should('have.value', 'qwertyuiopijn');

cy.get('button').click();

cy.get('img').should('have.length', 0);
cy.get('h2')
.contains(/No Data to display/i)
.should('be.visible');
});
});
5 changes: 5 additions & 0 deletions 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": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
6 changes: 6 additions & 0 deletions cypress/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import istanbul from '@cypress/code-coverage/task';

module.exports = (on, config) => {
on('task', istanbul);
return config;
};
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
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>
// }
// }
// }
1 change: 1 addition & 0 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@cypress/code-coverage/support';
21 changes: 21 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import '@cypress/code-coverage/support';
// ***********************************************************
// 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')
13 changes: 13 additions & 0 deletions index-back.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="/ok.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RS-REACT-TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<title>RS-REACT-TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<div id="root">not rendered</div>
<script type="module" src="/src/entry-client.tsx" async></script>
<replace />
</body>
</html>
Loading