diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab8d100..567f11e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,11 +17,17 @@ jobs: - name: Install npm dependencies run: yarn install - - name: Build - run: yarn build + - name: Build library package + run: yarn build:lib - # - name: Run tests - # run: yarn test + - name: Copy readme and license files + run: yarn build:copy-files + + - name: Run library tests + run: yarn test:lib --configuration=ci + + - name: Run demo app tests + run: yarn test:demo --configuration=ci - name: Run automated release process with semantic-release if: github.event_name == 'push' && contains(github.ref, 'master') diff --git a/angular.json b/angular.json index 8c0585f..8f630de 100644 --- a/angular.json +++ b/angular.json @@ -22,6 +22,13 @@ "main": "projects/ngx-sweetalert2/src/test.ts", "tsConfig": "projects/ngx-sweetalert2/tsconfig.spec.json", "karmaConfig": "projects/ngx-sweetalert2/karma.conf.js" + }, + "configurations": { + "ci": { + "watch": false, + "progress": false, + "browsers": "ChromeHeadlessCI" + } } }, "lint": { @@ -127,6 +134,13 @@ "projects/ngx-sweetalert2-demo/src/styles.css" ], "scripts": [] + }, + "configurations": { + "ci": { + "watch": false, + "progress": false, + "browsers": "ChromeHeadlessCI" + } } }, "lint": { diff --git a/projects/ngx-sweetalert2-demo/karma.conf.js b/projects/ngx-sweetalert2-demo/karma.conf.js index b368715..5a2f876 100644 --- a/projects/ngx-sweetalert2-demo/karma.conf.js +++ b/projects/ngx-sweetalert2-demo/karma.conf.js @@ -27,6 +27,12 @@ module.exports = function (config) { autoWatch: true, browsers: ['Chrome'], singleRun: false, - restartOnFileChange: true + restartOnFileChange: true, + customLaunchers: { + ChromeHeadlessCI: { + base: 'ChromeHeadless', + flags: ['--no-sandbox', '--disable-gpu'] + } + } }); }; diff --git a/projects/ngx-sweetalert2-demo/src/app/app.component.spec.ts b/projects/ngx-sweetalert2-demo/src/app/app.component.spec.ts index 4f4243b..12c48c8 100644 --- a/projects/ngx-sweetalert2-demo/src/app/app.component.spec.ts +++ b/projects/ngx-sweetalert2-demo/src/app/app.component.spec.ts @@ -13,7 +13,9 @@ describe('AppComponent', () => { RouterModule.forRoot([]), SweetAlert2Module.forRoot() ] - }).compileComponents(); + }); + + TestBed.compileComponents(); })); it('should create the app', () => { diff --git a/projects/ngx-sweetalert2/karma.conf.js b/projects/ngx-sweetalert2/karma.conf.js index 8ee856d..257eb1a 100644 --- a/projects/ngx-sweetalert2/karma.conf.js +++ b/projects/ngx-sweetalert2/karma.conf.js @@ -27,6 +27,12 @@ module.exports = function (config) { autoWatch: true, browsers: ['Chrome'], singleRun: false, - restartOnFileChange: true + restartOnFileChange: true, + customLaunchers: { + ChromeHeadlessCI: { + base: 'ChromeHeadless', + flags: ['--no-sandbox', '--disable-gpu'] + } + } }); }; diff --git a/projects/ngx-sweetalert2/src/lib/swal.component.spec.ts b/projects/ngx-sweetalert2/src/lib/swal.component.spec.ts index be26542..bf55610 100644 --- a/projects/ngx-sweetalert2/src/lib/swal.component.spec.ts +++ b/projects/ngx-sweetalert2/src/lib/swal.component.spec.ts @@ -1,6 +1,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { dismissOnDestroyToken, swalProviderToken } from './di'; import { SwalComponent } from './swal.component'; +import { SweetAlert2LoaderService } from './sweetalert2-loader.service'; describe('NgxSweetalert2Component', () => { let component: SwalComponent; @@ -8,9 +10,15 @@ describe('NgxSweetalert2Component', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + providers: [ + SweetAlert2LoaderService, + { provide: swalProviderToken, useValue: () => import('sweetalert2') }, + { provide: dismissOnDestroyToken, useValue: true } + ], declarations: [SwalComponent] - }) - .compileComponents(); + }); + + TestBed.compileComponents(); })); beforeEach(() => {