Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 8557b70

Browse files
committed
ci: add server tests
1 parent 4aa5fba commit 8557b70

File tree

14 files changed

+176
-24
lines changed

14 files changed

+176
-24
lines changed

.circleci/config.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
- *restore_cache
149149
- *attach_release_output
150150

151-
- run: yarn gulp ci:ssr
151+
- run: yarn test:ssr
152152

153153
# -------------------------------------------------------------------------
154154
# Job that pre-render's the universal app with `@angular/platform-server`.
@@ -191,6 +191,7 @@ jobs:
191191
- *checkout_code
192192
- *attach_release_output
193193
- yarn stamp
194+
194195
# CircleCI has a config setting to enforce SSH for all github connections.
195196
# This is not compatible with our mechanism of using a Personal Access Token
196197
# to publish the build snapshots. In order to fix this, we unset the global option.
@@ -222,6 +223,9 @@ workflows:
222223
- tests_saucelabs:
223224
requires:
224225
- build
226+
- tests_ssr:
227+
requires:
228+
- build
225229
- integration_tests:
226230
requires:
227231
- build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ src/apps/hello-world/package-lock.json
3636
src/apps/hello-world/yarn.lock
3737
yarn-error.log
3838
.angular/cache
39+
out-tsc

angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": 1,
44
"newProjectRoot": "projects/apps",
55
"projects": {
6-
"@libs/flex-layout": {
6+
"@angular/flex-layout": {
77
"projectType": "library",
88
"root": "projects/libs/flex-layout",
99
"sourceRoot": "projects/libs/flex-layout",
@@ -239,5 +239,5 @@
239239
}
240240
}
241241
},
242-
"defaultProject": "@libs/flex-layout"
242+
"defaultProject": "@angular/flex-layout"
243243
}

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"stamp": "ts-node tools/package-tools/version-placeholders.ts --module=commonjs",
2222
"build:universal-demo-app": "ng run universal-demo-app:build:production && ng run universal-demo-app:server",
2323
"test": "ng test",
24+
"test:ssr": "webpack --config test/webpack-spec-ssr-bundle.js && jasmine --config=test/jasmine-ssr.json",
2425
"lint": "stylelint projects/libs/**/*.scss --config=stylelint-config.json && tslint --project ./tsconfig.json --config tslint.json"
2526
},
2627
"private": true,
@@ -48,6 +49,7 @@
4849
"@angular/cdk": "^13.0.2",
4950
"@angular/cli": "~13.0.0",
5051
"@angular/compiler-cli": "~13.0.0",
52+
"@ngtools/webpack": "^13.0.3",
5153
"@types/jasmine": "~3.10.0",
5254
"@types/minimatch": "^3.0.5",
5355
"@types/node": "^12.11.1",
@@ -68,6 +70,8 @@
6870
"stylelint": "^14.1.0",
6971
"ts-node": "^10.4.0",
7072
"tslint": "^6.1.3",
71-
"typescript": "~4.4.3"
73+
"typescript": "~4.4.3",
74+
"webpack": "^5.64.1",
75+
"webpack-cli": "^4.9.1"
7276
}
7377
}

projects/libs/flex-layout/test.ssr.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import 'zone.js';
2+
import 'zone.js/testing';
3+
import 'zone.js/node';
4+
5+
import { getTestBed } from '@angular/core/testing';
6+
import {
7+
ServerTestingModule,
8+
platformServerTesting,
9+
} from '@angular/platform-server/testing';
10+
11+
// First, initialize the Angular testing environment.
12+
getTestBed().initTestEnvironment(ServerTestingModule, platformServerTesting());
13+
14+
declare const require: {
15+
context(
16+
path: string,
17+
deep?: boolean,
18+
filter?: RegExp
19+
): {
20+
keys(): string[];
21+
<T>(id: string): T;
22+
};
23+
};
24+
25+
// Then we find all the tests.
26+
const context = require.context('./', true, /\.spec\.ts$/);
27+
// And load the modules.
28+
context.keys().map(context);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
2+
{
3+
"extends": "../../../tsconfig.json",
4+
"compilerOptions": {
5+
"outDir": "../../../out-tsc/spec",
6+
"types": [
7+
"jasmine"
8+
]
9+
},
10+
"files": [
11+
"test.ssr.ts"
12+
],
13+
"include": [
14+
"**/*.spec.ts",
15+
"**/*.d.ts"
16+
]
17+
}

scripts/circleci/run-browserstack-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export BROWSER_STACK_ACCESS_KEY=`echo ${BROWSER_STACK_ACCESS_KEY} | rev`
1919
export TEST_PLATFORM="browserstack"
2020

2121
# Run the unit tests on Browserstack with Karma.
22-
yarn ng test @libs/flex-layout
22+
yarn ng test @angular/flex-layout
2323

2424
# Kill the Browserstack tunnel. This is necessary in order to avoid rate-limit
2525
# errors that cause the unit tests to be flaky.

scripts/circleci/run-local-browser-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ cd $(dirname ${0})/../..
1212
export TEST_PLATFORM="local"
1313

1414
# Run the unit tests on the local browsers with Karma.
15-
yarn ng test @libs/flex-layout
15+
yarn ng test @angular/flex-layout

scripts/circleci/run-saucelabs-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export SAUCE_ACCESS_KEY=`echo ${SAUCE_ACCESS_KEY} | rev`
1919
export TEST_PLATFORM="saucelabs"
2020

2121
# Run the unit tests on Saucelabs with Karma.
22-
yarn ng test @libs/flex-layout
22+
yarn ng test @angular/flex-layout
2323

2424
# Kill the Saucelabs tunnel. This is necessary in order to avoid rate-limit
2525
# errors that cause the unit tests to be flaky.

test/jasmine-ssr.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"spec_dir": "dist/packages/flex-layout",
3-
"spec_files": [
4-
"**/*.spec.js"
5-
],
6-
"random": true
2+
"spec_dir": "dist/spec/flex-layout",
3+
"spec_files": ["**/*.js"],
4+
"random": false
75
}

0 commit comments

Comments
 (0)