Skip to content

Commit

Permalink
setup cypress properly
Browse files Browse the repository at this point in the history
  • Loading branch information
feodorar committed Mar 5, 2023
1 parent c171704 commit f1e6fbd
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 42 deletions.
62 changes: 56 additions & 6 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
"outputPath": "dist/re-market",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": ["zone.js"],
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "sass",
"assets": ["src/favicon.ico", "src/assets"],
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.sass"
Expand Down Expand Up @@ -79,15 +84,60 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "sass",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.sass"],
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.sass"
],
"scripts": []
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "re-market:serve"
},
"configurations": {
"production": {
"devServerTarget": "re-market:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": true,
"headless": false
}
},
"e2e": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "re-market:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "re-market:serve:production"
}
}
}
}
}
},
"cli": {
"schematicCollections": [
"@cypress/schematic",
"@schematics/angular"
]
}
}
}
11 changes: 6 additions & 5 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { defineConfig } from "cypress";
import { defineConfig } from 'cypress'

export default defineConfig({

e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
'baseUrl': 'http://localhost:4200'
},
});


})
5 changes: 0 additions & 5 deletions cypress/e2e/offers.spec.cy.ts

This file was deleted.

5 changes: 5 additions & 0 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('My First Test', () => {
it('Visits the initial project page', () => {
cy.visit('/');
});
});
6 changes: 3 additions & 3 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
"name": "Using fixtures to represent data",
"email": "[email protected]"
}

40 changes: 23 additions & 17 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// This example namespace declaration will help
// with Intellisense and code completion in your
// IDE or Text Editor.
// ***********************************************
// declare namespace Cypress {
// interface Chainable<Subject = any> {
// customCommand(param: any): typeof customCommand;
// }
// }
//
// function customCommand(param: any): void {
// console.warn(param);
// }
//
// NOTE: You can use it like so:
// Cypress.Commands.add('customCommand', customCommand);
//
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
Expand All @@ -11,27 +28,16 @@
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
// 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>
// }
// }
// }
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
7 changes: 2 additions & 5 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
// When a command from ./commands is ready to use, import with `import './commands'` syntax
// import './commands';
8 changes: 8 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"include": ["**/*.ts"],
"compilerOptions": {
"sourceMap": false,
"types": ["cypress"]
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"generate-api": "npx @openapitools/openapi-generator-cli generate -i openapi/remarket-openapi.yml -g typescript-angular -o openapi/generated",
"start-wiremock": "java -jar e2e/wiremock-config/wiremock-standalone.jar --root-dir e2e/wiremock-config --port 9000 --local-response-templating",
"start-prism-mockserver": "prism mock openapi/remarket-openapi.yml",
"cypress:open": "cypress open"
"e2e": "npm run start-wiremock & ng e2e",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
"private": true,
"dependencies": {
Expand Down

0 comments on commit f1e6fbd

Please sign in to comment.