Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oktaal committed Apr 25, 2023
1 parent f5676bc commit 08271e0
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 9 deletions.
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"zone.js/testing"
],
"tsConfig": "elements/tsconfig.spec.json",
"karmaConfig": "elements/karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"elements/src/favicon.ico",
Expand Down
60 changes: 60 additions & 0 deletions elements/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
let configuration = {
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-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/frontend'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false,
customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: [
'--headless',
'--remote-debugging-port=9222',
],
}
},
restartOnFileChange: true
}

if (process.env.CI) {
configuration.browsers = ['ChromeHeadless'];
configuration.singleRun = true;
}

config.set(configuration);
};
6 changes: 4 additions & 2 deletions elements/src/app/view-wrapper/view-wrapper.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ViewWrapperComponent } from './view-wrapper.component';
import { LuupzigModule } from 'luupzig';

describe('ViewWrapperComponent', () => {
let component: ViewWrapperComponent;
let fixture: ComponentFixture<ViewWrapperComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ViewWrapperComponent ]
declarations: [ViewWrapperComponent],
imports: [LuupzigModule]
})
.compileComponents();
.compileComponents();

fixture = TestBed.createComponent(ViewWrapperComponent);
component = fixture.componentInstance;
Expand Down
11 changes: 4 additions & 7 deletions frontend/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { LuupzigModule } from 'luupzig';

describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [
LuupzigModule
]
}).compileComponents();
});

Expand All @@ -21,11 +25,4 @@ describe('AppComponent', () => {
const app = fixture.componentInstance;
expect(app.title).toEqual('frontend');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('frontend app is running!');
});
});

0 comments on commit 08271e0

Please sign in to comment.