Run browser tests in CI (#10)
continuous-integration/drone/push Build is passing Details

Co-authored-by: clfreville2 <clement.freville2@etu.uca.fr>
Reviewed-on: #10
Reviewed-by: Bastien OLLIER <bastien.ollier@noreply.codefirst.iut.uca.fr>
chore/angular18
Clément FRÉVILLE 6 months ago
parent 7dfd83b60a
commit 38eae2ed53

@ -9,6 +9,13 @@ steps:
- npm install
- npm run build
- name: test-chrome
image: timbru31/node-chrome:20-slim
commands:
- npm run test -- --browsers=ChromeHeadlessCI --watch=false
depends_on:
- build
- name: sonar
image: sonarsource/sonar-scanner-cli:5
commands:

@ -71,7 +71,8 @@
"tsConfig": "tsconfig.spec.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
"scripts": [],
"karmaConfig": "karma.conf.js"
}
},
"lint": {

@ -0,0 +1,46 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/sandkasten'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
browsers: ['Chrome', 'Firefox'],
restartOnFileChange: true,
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
}
});
};

28
package-lock.json generated

@ -50,6 +50,7 @@
"karma": "~6.4.2",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.1",
"karma-firefox-launcher": "^2.1.3",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"prettier": "^3.2.5",
@ -9660,6 +9661,33 @@
"node": "*"
}
},
"node_modules/karma-firefox-launcher": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.3.tgz",
"integrity": "sha512-LMM2bseebLbYjODBOVt7TCPP9OI2vZIXCavIXhkO9m+10Uj5l7u/SKoeRmYx8FYHTVGZSpk6peX+3BMHC1WwNw==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-wsl": "^2.2.0",
"which": "^3.0.0"
}
},
"node_modules/karma-firefox-launcher/node_modules/which": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz",
"integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==",
"dev": true,
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/which.js"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"node_modules/karma-jasmine": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-5.1.0.tgz",

@ -54,6 +54,7 @@
"karma": "~6.4.2",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.1",
"karma-firefox-launcher": "^2.1.3",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"prettier": "^3.2.5",

@ -1,11 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import { TranslateModule } from '@ngx-translate/core';
import { RouterModule } from '@angular/router';
describe('AppComponent', () => {
beforeEach(() =>
TestBed.configureTestingModule({
imports: [RouterTestingModule, AppComponent],
imports: [
RouterModule.forRoot([]),
AppComponent,
TranslateModule.forRoot(),
],
})
);
@ -19,8 +24,6 @@ describe('AppComponent', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.content span')?.textContent).toContain(
'sandkasten app is running!'
);
expect(compiled.textContent).toContain('HeaderPage.Editor');
});
});

@ -1,6 +1,8 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HeaderComponent } from './header.component';
import { TranslateModule } from '@ngx-translate/core';
import { RouterModule } from '@angular/router';
describe('HeaderComponent', () => {
let component: HeaderComponent;
@ -8,7 +10,11 @@ describe('HeaderComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HeaderComponent],
imports: [
RouterModule.forRoot([]),
HeaderComponent,
TranslateModule.forRoot(),
],
});
fixture = TestBed.createComponent(HeaderComponent);
component = fixture.componentInstance;

@ -1,6 +1,8 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LandingPageComponent } from './landing-page.component';
import { TranslateModule } from '@ngx-translate/core';
import { RouterModule } from '@angular/router';
describe('LandingPageComponent', () => {
let component: LandingPageComponent;
@ -8,7 +10,11 @@ describe('LandingPageComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [LandingPageComponent],
imports: [
RouterModule.forRoot([]),
LandingPageComponent,
TranslateModule.forRoot(),
],
});
fixture = TestBed.createComponent(LandingPageComponent);
component = fixture.componentInstance;

@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PrivacyPolicyComponent } from './privacy-policy.component';
import { TranslateModule } from '@ngx-translate/core';
describe('PrivacyPolicyComponent', () => {
let component: PrivacyPolicyComponent;
@ -8,7 +9,7 @@ describe('PrivacyPolicyComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PrivacyPolicyComponent],
imports: [PrivacyPolicyComponent, TranslateModule.forRoot()],
}).compileComponents();
fixture = TestBed.createComponent(PrivacyPolicyComponent);

@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TermsOfServiceComponent } from './terms-of-service.component';
import { TranslateModule } from '@ngx-translate/core';
describe('TermsOfServiceComponent', () => {
let component: TermsOfServiceComponent;
@ -8,7 +9,7 @@ describe('TermsOfServiceComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [TermsOfServiceComponent],
imports: [TermsOfServiceComponent, TranslateModule.forRoot()],
}).compileComponents();
fixture = TestBed.createComponent(TermsOfServiceComponent);

Loading…
Cancel
Save