Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,33 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

# Download Jest coverage from generate-and-backend-tests job
- name: Download jest coverage artifact
uses: actions/download-artifact@v4
with:
name: jest-coverage
path: jest-coverage/

# Download Cypress coverage from cypress-zigbee job
- name: Download cypress-zigbee coverage artifact
uses: actions/download-artifact@v4
with:
name: cypress-zigbee-coverage
path: cypress-coverage/
continue-on-error: true

- run: sudo ./src-script/install-packages-ubuntu
- run: sudo apt-get install --fix-missing xvfb
- run: npm ci
- run: npm run report
- run: npm run version-stamp
- run: npm rebuild canvas --update-binary
- run: npm rebuild libxmljs --update-binary
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we are adding these new commands here from line 150-154


# Combine Jest and Cypress coverage and enforce 80% threshold
- name: Combine coverage and check 80% threshold
run: npm run coverage:combine

- name: Codecov
uses: codecov/[email protected]

Expand Down
8 changes: 7 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ module.exports = (api) => {
presets: [
['@quasar/babel-preset-app', envOptions],
'@babel/preset-typescript'
]
],
plugins: [
// Add Istanbul plugin for code coverage instrumentation when testing
process.env.NODE_ENV === 'test' && 'istanbul',
// Add coverage plugin for Cypress
process.env.CYPRESS_COVERAGE && 'istanbul'
].filter(Boolean)
}
}
12 changes: 11 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ export default defineConfig({
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
require('@cypress/code-coverage/task')(on, config)

// Optional: Add coverage configuration
on('task', {
coverage(coverage) {
// Custom coverage processing if needed
return null
}
})

return config
},
testIsolation: false,
excludeSpecPattern: [
Expand Down
8 changes: 8 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
import '@cypress/code-coverage/support'

// Collect coverage from window object
Cypress.on('window:before:load', (win) => {
if (win.__coverage__) {
// Coverage data is available
console.log('Coverage data found on window object')
}
})
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ module.exports = {
coveragePathIgnorePatterns: [
'/node_modules/',
'<rootDir>/src-electron/generator/matter/darwin/Framework/CHIP/templates/helper.js'
]
],
testEnvironment: 'jsdom'
}
115 changes: 79 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 28 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
"test:unit:watch": "jest --watch",
"test:unit:watchAll": "jest --watchAll",
"test:e2e": "node src-script/zap-uitest.js open zigbee",
"test:e2e-ci": "node src-script/zap-uitest.js run zigbee",
"test:e2e-ci": "cross-env NODE_ENV=test CYPRESS_COVERAGE=true node src-script/zap-uitest.js run zigbee",
"test:e2e-coverage": "npm run test:e2e-ci && npm run coverage:combine",
"coverage:combine": "node src-script/zap-combine-reports.js",
"test:coverage": "npm run test:unit:coverage && npm run test:e2e-ci && npm run coverage:combine",
"test:e2e-matter": "node src-script/zap-uitest.js open matter",
"test:e2e-matter-ci": "node src-script/zap-uitest.js run matter",
"report": "node src-script/zap-combine-reports.js",
Expand Down Expand Up @@ -173,6 +176,7 @@
"@vue/test-utils": "^2.4.6",
"7zip-bin": "^5.2.0",
"autoprefixer": "^10.4.20",
"babel-plugin-istanbul": "^7.0.1",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"cypress": "^13.6.6",
Expand Down Expand Up @@ -206,10 +210,10 @@
"pkg": "^5.8.1",
"prettier": "^3.3.3",
"pretty-quick": "^4.0.0",
"sonar-scanner": "^3.1.0",
"test-utils": "^1.1.1",
"typescript": "4.6",
"workbox-webpack-plugin": "^7.1.0",
"sonar-scanner": "^3.1.0"
"workbox-webpack-plugin": "^7.1.0"
},
"engines": {
"node": ">= 8.9.0",
Expand Down Expand Up @@ -314,13 +318,30 @@
},
"nyc": {
"report-dir": "cypress-coverage",
"reporter": [
"json",
"lcov",
"text"
],
"include": [
"src/**/*.js",
"src/**/*.ts",
"src-electron/**/*.js",
"src-electron/**/*.ts",
"src-shared/**/*.js",
"src-shared/**/*.ts"
"src-shared/**/*.js"
],
"exclude": [
"**/*.test.js",
"**/*.spec.js",
"**/node_modules/**",
"cypress/**/*",
"dist/**/*"
],
"all": true,
"cache": false,
"instrument": true,
"sourceMap": false,
"extension": [
".js",
".vue"
]
},
"pkg": {
Expand Down
34 changes: 34 additions & 0 deletions quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// https://quasar.dev/quasar-cli/quasar-conf-js
const ESLintPlugin = require('eslint-webpack-plugin')
const { configure } = require('quasar/wrappers')
const path = require('path')

module.exports = configure(function (ctx) {
return {
Expand Down Expand Up @@ -84,6 +85,39 @@ module.exports = configure(function (ctx) {
loader: 'file-loader',
exclude: /node_modules/
})
},
chainWebpack(chain, { isServer, isClient }) {
// Add Istanbul loader for coverage when testing
if (process.env.CYPRESS_COVERAGE) {
// Handle JS files
chain.module
.rule('istanbul-js')
.test(/\.js$/)
.enforce('post')
.include.add(path.resolve(__dirname, 'src'))
.add(path.resolve(__dirname, 'src-electron'))
.add(path.resolve(__dirname, 'src-shared'))
.end()
.exclude.add(/node_modules/)
.add(/\.spec\.js$/)
.add(/cypress/)
.end()
.use('istanbul-instrumenter-loader')
.loader('istanbul-instrumenter-loader')
.options({
esModules: true
})

// Handle Vue files - target the compiled JavaScript from vue-loader
chain.module
.rule('vue')
.use('istanbul-instrumenter-loader')
.loader('istanbul-instrumenter-loader')
.options({
esModules: true
})
.before('vue-loader')
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we add istanbul dependency here? What does it do?

}
},

Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sonar.organization=project-chip
#sonar.projectKey=watt_zap
sonar.projectName=Zcl Advanced Platform
sonar.sources=src,src-electron,src-shared
sonar.javascript.lcov.reportPaths=jest-coverage/lcov.info,cypress-coverage/lcov.info
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.host.url=https://sonarqube.silabs.net
sonar.token=put your token here which can be created from the above url
# sonar.plsql.jdbc.url=test/.zap/test-server.sqlite
Expand Down
Loading
Loading