Skip to content

Commit 76dff6a

Browse files
authored
ci(lit): add browser-based integration testing to lit explorer (a2ui-project#1545)
Sets up the integration testing infrastructure for the Lit renderer explorer application. * Adds Karma and Jasmine to run ChromeHeadless tests * Expands the Lit test workflow to run the new integration tests (previously this was only running unit tests) * Adds a sample integration test to see how everything works together
1 parent 9976ad0 commit 76dff6a

14 files changed

Lines changed: 3120 additions & 675 deletions

File tree

.github/workflows/lit_build_and_test.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,36 @@ permissions:
3333
jobs:
3434
build-and-test:
3535
runs-on: ubuntu-latest
36-
36+
strategy:
37+
matrix:
38+
task: [unit, integration]
3739
steps:
3840
- uses: actions/checkout@v6
39-
4041
- name: Set up Node.js
4142
uses: actions/setup-node@v6
4243
with:
4344
node-version: "22"
4445

45-
- name: Install web_core dependencies
46-
working-directory: ./renderers/web_core
47-
run: npm i
48-
46+
# Unit tests need to build the Lit renderer
4947
- name: Build web_core
48+
if: matrix.task == 'unit'
5049
working-directory: ./renderers/web_core
51-
run: npm run build
52-
53-
- name: Install Lit renderer dependencies
54-
working-directory: ./renderers/lit
55-
run: npm i
56-
50+
run: npm i && npm run build
5751
- name: Build Lit renderer
52+
if: matrix.task == 'unit'
5853
working-directory: ./renderers/lit
59-
run: npm run build
54+
run: npm i && npm run build
55+
- name: Run unit tests
56+
if: matrix.task == 'unit'
57+
working-directory: ./renderers/lit
58+
run: npm run test:unit
6059

61-
- name: Run Lit renderer tests
60+
# Integration tests take care of build:deps in the app under test
61+
- name: Install Lit deps
62+
if: matrix.task == 'integration'
63+
working-directory: ./renderers/lit
64+
run: npm i
65+
- name: Run integration tests
66+
if: matrix.task == 'integration'
6267
working-directory: ./renderers/lit
63-
run: npm test
68+
run: npm run test:integration
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist
33
public/specs
4+
src/generated/
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
const path = require('path');
18+
19+
module.exports = function (config) {
20+
config.set({
21+
basePath: '',
22+
frameworks: ['jasmine'],
23+
plugins: [require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-esbuild')],
24+
files: [{pattern: 'tests/**/*.test.ts', watched: true}],
25+
preprocessors: {
26+
'tests/**/*.test.ts': ['esbuild'],
27+
},
28+
esbuild: {
29+
tsconfig: './tsconfig.json',
30+
target: 'es2022',
31+
format: 'iife',
32+
sourcemap: true,
33+
alias: {
34+
// Map @a2ui/lit packages directly to their TypeScript source files.
35+
// This allows tests to run against live code changes without requiring
36+
// a rebuild step first.
37+
'@a2ui/lit/v0_9': path.resolve(__dirname, '../src/v0_9/index.ts'),
38+
'@a2ui/lit': path.resolve(__dirname, '../src/index.ts'),
39+
},
40+
},
41+
reporters: ['progress'],
42+
port: 9876,
43+
colors: true,
44+
logLevel: config.LOG_INFO,
45+
autoWatch: false,
46+
browsers: ['ChromeHeadless'],
47+
singleRun: true,
48+
concurrency: Infinity,
49+
hostname: '127.0.0.1',
50+
listenAddress: '127.0.0.1',
51+
captureTimeout: 210000,
52+
browserNoActivityTimeout: 210000,
53+
browserDisconnectTimeout: 10000,
54+
browserDisconnectTolerance: 3,
55+
});
56+
};

0 commit comments

Comments
 (0)