Skip to content

Commit 4e319c7

Browse files
committed
ci(circle): run tests on circle instead of travis
1 parent 1919978 commit 4e319c7

File tree

11 files changed

+160
-158
lines changed

11 files changed

+160
-158
lines changed

.circleci/config.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# CircleCI configuration for @thisissoon/angular-image-loader
3+
#
4+
5+
version: 2
6+
7+
jobs:
8+
setup:
9+
working_directory: ~/@thisissoon/angular-image-loader
10+
docker:
11+
- image: circleci/node:8-browsers
12+
steps:
13+
- checkout
14+
- restore_cache:
15+
key: ~/@thisissoon/angular-image-loader-{{ .Branch }}-{{ checksum "package.json" }}
16+
- run: yarn --silent
17+
- save_cache:
18+
key: ~/@thisissoon/angular-image-loader-{{ .Branch }}-{{ checksum "package.json" }}
19+
paths:
20+
- 'node_modules'
21+
22+
test:
23+
working_directory: ~/@thisissoon/angular-image-loader
24+
docker:
25+
- image: circleci/node:8-browsers
26+
steps:
27+
- checkout
28+
- restore_cache:
29+
key: ~/@thisissoon/angular-image-loader-{{ .Branch }}-{{ checksum "package.json" }}
30+
- run: yarn lint
31+
- run: yarn test --configuration ci
32+
- run: yarn e2e
33+
- run: yarn coverage
34+
35+
workflows:
36+
version: 2
37+
setup_and_test:
38+
jobs:
39+
- setup
40+
- test:
41+
requires:
42+
- setup

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ npm-debug.log
3535
testem.log
3636
/typings
3737

38-
# e2e
39-
/e2e/*.js
40-
/e2e/*.map
41-
4238
# System Files
4339
.DS_Store
4440
Thumbs.db

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

angular.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"with": "src/environments/environment.prod.ts"
3838
}
3939
]
40+
},
41+
"no-progress": {
42+
"progress": false
4043
}
4144
}
4245
},
@@ -48,6 +51,9 @@
4851
"configurations": {
4952
"production": {
5053
"browserTarget": "angular-image-loader:build:production"
54+
},
55+
"no-progress": {
56+
"browserTarget": "angular-image-loader:build:no-progress"
5157
}
5258
}
5359
},
@@ -61,12 +67,20 @@
6167
"builder": "@angular-devkit/build-angular:karma",
6268
"options": {
6369
"main": "src/test.ts",
64-
"karmaConfig": "./karma.conf.js",
70+
"karmaConfig": "./src/karma.conf.js",
6571
"polyfills": "src/polyfills.ts",
6672
"tsConfig": "src/tsconfig.spec.json",
6773
"scripts": [],
6874
"styles": ["src/styles.scss"],
6975
"assets": ["src/assets", "src/favicon.ico"]
76+
},
77+
"configurations": {
78+
"ci": {
79+
"browsers": "ChromeHeadless",
80+
"codeCoverage": true,
81+
"progress": false,
82+
"watch": false
83+
}
7084
}
7185
},
7286
"lint": {
@@ -86,8 +100,8 @@
86100
"e2e": {
87101
"builder": "@angular-devkit/build-angular:protractor",
88102
"options": {
89-
"protractorConfig": "./protractor.conf.js",
90-
"devServerTarget": "angular-image-loader:serve"
103+
"protractorConfig": "./e2e/protractor.conf.js",
104+
"devServerTarget": "angular-image-loader:serve:no-progress"
91105
}
92106
},
93107
"lint": {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ const { SpecReporter } = require('jasmine-spec-reporter');
55

66
exports.config = {
77
allScriptsTimeout: 11000,
8-
specs: ['./e2e/**/*.e2e-spec.ts'],
8+
specs: ['./src/**/*.e2e-spec.ts'],
99
capabilities: {
1010
browserName: 'chrome',
1111
chromeOptions: {
12-
args: ['--no-sandbox', '--window-size=1024,768']
12+
args: ['--headless', '--no-sandbox', '--window-size=1024,768']
1313
}
1414
},
1515
directConnect: true,
1616
baseUrl: 'http://localhost:4200/',
1717
framework: 'jasmine',
1818
jasmineNodeOpts: {
1919
showColors: true,
20-
defaultTimeoutInterval: 10000,
20+
defaultTimeoutInterval: 30000,
2121
print: function() {}
2222
},
2323
onPrepare() {
2424
require('ts-node').register({
25-
project: 'e2e/tsconfig.e2e.json'
25+
project: require('path').join(__dirname, './tsconfig.e2e.json')
2626
});
2727
jasmine
2828
.getEnv()

e2e/app.po.ts renamed to e2e/src/app.po.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ export class AppPage {
88
scrollTo(x: number = 0, y: number = 0) {
99
browser.executeScript(`return window.scrollTo(${x}, ${y});`);
1010
return browser.wait(() =>
11-
this.getScrollYPosition()
12-
.then((posY) => posY === y));
11+
this.getScrollYPosition().then(posY => posY === y)
12+
);
1313
}
1414

1515
scrollIntoView(selector: string) {
16-
return browser.executeScript(`return document.querySelector('${selector}').scrollIntoView()`);
16+
return browser.executeScript(
17+
`return document.querySelector('${selector}').scrollIntoView()`
18+
);
1719
}
1820

1921
scrollToImageTopElement() {
@@ -32,14 +34,21 @@ export class AppPage {
3234
}
3335

3436
setWindowSize(x: number, y: number) {
35-
browser.driver.manage().window().setSize(x, y);
37+
browser.driver
38+
.manage()
39+
.window()
40+
.setSize(x, y);
3641
return browser.wait(() =>
37-
this.getWindowSize()
38-
.then((size: any) => size.height === y && size.width === x));
42+
this.getWindowSize().then(
43+
(size: any) => size.height === y && size.width === x
44+
)
45+
);
3946
}
4047

4148
getWindowSize() {
42-
return browser.executeScript(`return { height: window.outerHeight, width: window.outerWidth };`);
49+
return browser.executeScript(
50+
`return { height: window.outerHeight, width: window.outerWidth };`
51+
);
4352
}
4453

4554
getScrollYPosition() {
@@ -54,7 +63,6 @@ export class AppPage {
5463
return element(by.css('.sn-image-loader--bottom'));
5564
}
5665

57-
5866
getImageTopLoaderCompClass() {
5967
return this.getImageTopLoaderComp().getAttribute('class');
6068
}
@@ -116,18 +124,21 @@ export class AppPage {
116124
}
117125

118126
isImageTopLoaded() {
119-
return this.getImageTopLoaderCompClass()
120-
.then((result: string) => result.includes('sn-image-loaded'));
127+
return this.getImageTopLoaderCompClass().then((result: string) =>
128+
result.includes('sn-image-loaded')
129+
);
121130
}
122131

123132
isImageBottomLoaded() {
124-
return this.getImageBottomLoaderCompClass()
125-
.then((result: string) => result.includes('sn-image-loaded'));
133+
return this.getImageBottomLoaderCompClass().then((result: string) =>
134+
result.includes('sn-image-loaded')
135+
);
126136
}
127137

128138
isVideoLoaded() {
129-
return this.getVideoElementClass()
130-
.then((result: string) => result.includes('sn-video-loaded'));
139+
return this.getVideoElementClass().then((result: string) =>
140+
result.includes('sn-video-loaded')
141+
);
131142
}
132143

133144
waitForImageTopElementLoaded() {
Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { AppPage } from './app.po';
21
import { browser } from 'protractor';
3-
import { image } from '../src/app/app-data';
42

5-
describe('ImageLoader Lib E2E Tests', function () {
3+
import { AppPage } from './app.po';
4+
import { image } from '../../src/app/app-data';
5+
6+
describe('ImageLoader Lib E2E Tests', function() {
67
let page: AppPage;
78

89
beforeEach(() => {
@@ -13,10 +14,11 @@ describe('ImageLoader Lib E2E Tests', function () {
1314

1415
afterEach(() => {
1516
// ensure no errors appear in console
16-
browser.manage()
17+
browser
18+
.manage()
1719
.logs()
1820
.get('browser')
19-
.then((browserLog) => {
21+
.then(browserLog => {
2022
expect(browserLog).toEqual([]);
2123
});
2224
});
@@ -45,11 +47,12 @@ describe('ImageLoader Lib E2E Tests', function () {
4547

4648
const resultLoaded = page.isImageTopLoaded();
4749
const resultSrcset = page.getImageTopElementSrcSet();
48-
const expectedSrcset = `${image.images[0].x1} 1x, ${image.images[0].x2} 2x`;
50+
const expectedSrcset = `${image.images[0].x1} 1x, ${
51+
image.images[0].x2
52+
} 2x`;
4953
expect(resultLoaded).toBeTruthy();
5054
expect(resultSrcset).toEqual(expectedSrcset);
5155
});
52-
5356
});
5457

5558
describe('lazy load image', () => {
@@ -71,27 +74,26 @@ describe('ImageLoader Lib E2E Tests', function () {
7174
expectedSrc = image.images[0].x1;
7275
expect(resultLoaded).toEqual(expectedLoaded);
7376
expect(resultSrc).toEqual(expectedSrc);
74-
7577
});
7678

7779
it('should update image loaded count element when image scrolled into viewport', () => {
7880
expect(page.getImageBottomLoadedCountElementText()).toEqual('0');
7981
page.scrollToImageBottomElement();
8082
expect(page.getImageBottomLoadedCountElementText()).toEqual('1');
8183
});
82-
8384
});
8485

8586
describe('responsive image', () => {
86-
8787
it('should load correct image for "xs" device size', () => {
8888
page.setWindowSize(400, 580);
8989
page.scrollToImageBottomElement();
9090

9191
const resultLoaded = page.isImageBottomLoaded();
9292
const expectedLoaded = true;
9393
const resultSrcset = page.getImageBottomElementSrcSet();
94-
const expectedSrcset = `${image.images[0].x1} 1x, ${image.images[0].x2} 2x`;
94+
const expectedSrcset = `${image.images[0].x1} 1x, ${
95+
image.images[0].x2
96+
} 2x`;
9597

9698
expect(resultLoaded).toEqual(expectedLoaded);
9799
expect(resultSrcset).toEqual(expectedSrcset);
@@ -104,7 +106,9 @@ describe('ImageLoader Lib E2E Tests', function () {
104106
const resultLoaded = page.isImageBottomLoaded();
105107
const expectedLoaded = true;
106108
const resultSrcset = page.getImageBottomElementSrcSet();
107-
const expectedSrcset = `${image.images[1].x1} 1x, ${image.images[1].x2} 2x`;
109+
const expectedSrcset = `${image.images[1].x1} 1x, ${
110+
image.images[1].x2
111+
} 2x`;
108112

109113
expect(resultLoaded).toEqual(expectedLoaded);
110114
expect(resultSrcset).toEqual(expectedSrcset);
@@ -117,7 +121,9 @@ describe('ImageLoader Lib E2E Tests', function () {
117121
const resultLoaded = page.isImageBottomLoaded();
118122
const expectedLoaded = true;
119123
const resultSrcset = page.getImageBottomElementSrcSet();
120-
const expectedSrcset = `${image.images[2].x1} 1x, ${image.images[2].x2} 2x`;
124+
const expectedSrcset = `${image.images[2].x1} 1x, ${
125+
image.images[2].x2
126+
} 2x`;
121127

122128
expect(resultLoaded).toEqual(expectedLoaded);
123129
expect(resultSrcset).toEqual(expectedSrcset);
@@ -146,8 +152,5 @@ describe('ImageLoader Lib E2E Tests', function () {
146152
expected = '3';
147153
expect(result).toEqual(expected);
148154
});
149-
150155
});
151-
152156
});
153-

0 commit comments

Comments
 (0)