diff --git a/angular.json b/angular.json index 9e4a796..6f5c1f6 100644 --- a/angular.json +++ b/angular.json @@ -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" @@ -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" + ] } -} +} \ No newline at end of file diff --git a/cypress.config.ts b/cypress.config.ts index 17161e3..03ef9d1 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -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' }, -}); + + +}) \ No newline at end of file diff --git a/cypress/e2e/offers.spec.cy.ts b/cypress/e2e/offers.spec.cy.ts deleted file mode 100644 index 9387057..0000000 --- a/cypress/e2e/offers.spec.cy.ts +++ /dev/null @@ -1,5 +0,0 @@ -describe('template spec', () => { - it('passes', () => { - cy.visit('/offers'); - }); -}); diff --git a/cypress/e2e/spec.cy.ts b/cypress/e2e/spec.cy.ts new file mode 100644 index 0000000..26c1c32 --- /dev/null +++ b/cypress/e2e/spec.cy.ts @@ -0,0 +1,5 @@ +describe('My First Test', () => { + it('Visits the initial project page', () => { + cy.visit('/'); + }); +}); diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json index 02e4254..20b22a1 100644 --- a/cypress/fixtures/example.json +++ b/cypress/fixtures/example.json @@ -1,5 +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" + "name": "Using fixtures to represent data", + "email": "hello@cypress.io" } + \ No newline at end of file diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 698b01a..af1f44a 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -1,6 +1,23 @@ -/// // *********************************************** -// 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 { +// 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. // @@ -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 -// drag(subject: string, options?: Partial): Chainable -// dismiss(subject: string, options?: Partial): Chainable -// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable -// } -// } -// } \ No newline at end of file +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index f80f74f..55540ff 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -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') \ No newline at end of file +// When a command from ./commands is ready to use, import with `import './commands'` syntax +// import './commands'; diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json new file mode 100644 index 0000000..79d78d7 --- /dev/null +++ b/cypress/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "include": ["**/*.ts"], + "compilerOptions": { + "sourceMap": false, + "types": ["cypress"] + } +} diff --git a/package.json b/package.json index 020ca0b..9fc5e4b 100644 --- a/package.json +++ b/package.json @@ -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": {