From 0248b8131ae77c7da55e1881e933b0e9890c187a Mon Sep 17 00:00:00 2001 From: Jacobe2169 Date: Mon, 11 Mar 2024 15:36:55 +0100 Subject: [PATCH] debug component testing --- frontend/cypress.config.ts | 26 ++---------------- ...=> acquisition-frameworks.component.cy.ts} | 27 ++++++++++++------- 2 files changed, 19 insertions(+), 34 deletions(-) rename frontend/src/app/GN2CommonModule/form/acquisition-frameworks/{acquisition-frameworks.component.spec.ts => acquisition-frameworks.component.cy.ts} (64%) diff --git a/frontend/cypress.config.ts b/frontend/cypress.config.ts index ae517177f9..e34587e6ff 100644 --- a/frontend/cypress.config.ts +++ b/frontend/cypress.config.ts @@ -17,36 +17,14 @@ export default defineConfig({ }, baseUrl: "http://127.0.0.1:4200", specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}", + supportFile: false, }, component: { devServer: { framework: "angular", bundler: "webpack", - options: { - projectConfig: { - root: 'src', - sourceRoot: 'src/app', - buildOptions: { - // outputPath: 'dist/my-app', - // index: 'apps/my-app/src/index.html', - // main: 'apps/my-app/src/main.ts', - // polyfills: 'apps/my-app/src/polyfills.ts', - tsConfig: 'tsconfig.spec.json', - // inlineStyleLanguage: 'scss', - // assets: ['apps/my-app/src/favicon.ico', 'apps/my-app/src/assets'], - // styles: ['apps/my-app/src/styles.scss'], - // scripts: [], - // buildOptimizer: false, - // optimization: false, - // vendorChunk: true, - // extractLicenses: false, - // sourceMap: true, - // namedChunks: true, - }, - }, - }, }, - specPattern: "**/*.spec.ts", + specPattern: "**/*.cy.ts", }, }); diff --git a/frontend/src/app/GN2CommonModule/form/acquisition-frameworks/acquisition-frameworks.component.spec.ts b/frontend/src/app/GN2CommonModule/form/acquisition-frameworks/acquisition-frameworks.component.cy.ts similarity index 64% rename from frontend/src/app/GN2CommonModule/form/acquisition-frameworks/acquisition-frameworks.component.spec.ts rename to frontend/src/app/GN2CommonModule/form/acquisition-frameworks/acquisition-frameworks.component.cy.ts index f0dcae0fdb..44f4a6f418 100644 --- a/frontend/src/app/GN2CommonModule/form/acquisition-frameworks/acquisition-frameworks.component.spec.ts +++ b/frontend/src/app/GN2CommonModule/form/acquisition-frameworks/acquisition-frameworks.component.cy.ts @@ -6,25 +6,28 @@ import { Component, OnInit } from '@angular/core'; import { ConfigService } from '../../../services/config.service'; import { MountConfig } from 'cypress/angular'; -import { HttpClient } from '@angular/common/http'; -import { GN2CommonModule } from '../../GN2Common.module'; +import { HttpClient, HttpHandler } from '@angular/common/http'; +import * as gerard from '../../GN2Common.module'; @Component({ selector: 'pnx-pouet', template: '

POUET POUET

', }) export class testComponent implements OnInit { - constructor(configService: ConfigService) {} + constructor(configService: ConfigService) { } - ngOnInit() {} + ngOnInit() { } } +export abstract class ConfigMock { + +} describe('testComponent', () => { - const config: MountConfig = { - imports: [GN2CommonModule], - providers: [ConfigService, HttpClient] - } + // const config: MountConfig = { + // imports: [GN2CommonModule], + // providers: [ConfigService, HttpClient] + // } @@ -38,8 +41,12 @@ describe('testComponent', () => { // cy.get('.name').should('have.value', 'my custom message') // console.log(cy.stub(_ds, "getAcquisitionFrameworks").returns({})) - - cy.mount(testComponent, config) + console.log("test") + cy.mount(testComponent, { + imports: [], + declarations: [testComponent], + providers: [{ provide: ConfigService, useClass: ConfigMock }] + }) }); });