Skip to content

Commit

Permalink
Merge pull request #3 from conestack/js_action
Browse files Browse the repository at this point in the history
add js actin
  • Loading branch information
rnixx committed May 11, 2022
2 parents 2fd3a28 + bee30d7 commit 7d44c54
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/test_js.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: JS Test chosen

on:
push:
paths:
- '**.js'

jobs:
test:
name: TEST CHOSEN

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install
run: |
npm --save-dev install \
qunit \
karma \
karma-qunit \
karma-coverage \
karma-chrome-launcher \
karma-module-resolver-preprocessor
npm --no-save install https://github.com/jquery/jquery#main
- name: Run tests
run: |
node_modules/karma/bin/karma start js/karma.conf.js
- name: Run coverage
run: |
npm run karma-test:coverage
4 changes: 3 additions & 1 deletion .github/workflows/test_py.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Test chosen
name: PY Test chosen

on:
push:
paths:
- '**.py'

jobs:
test:
Expand Down
17 changes: 17 additions & 0 deletions js/karma-coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const percentage = {
lines: 33,
statements: 33,
functions: 28,
branches: 8
}
var summary = require('./karma/coverage/coverage-summary.json');

for (let res in summary.total) {
if (summary.total[res].pct < percentage[res]) {
throw new Error(
`Coverage too low on ${res},
expected: ${percentage[res]},
got: ${summary.total[res].pct}`
);
}
}
13 changes: 13 additions & 0 deletions js/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ module.exports = function(config) {
'progress',
'coverage'
],
coverageReporter: {
reporters: [
{
type: 'json-summary',
dir: 'coverage/',
subdir: '.'
}, {
type: 'html',
dir: 'coverage/',
subdir: 'chrome-headless'
}
]
},
preprocessors: {
'../src/*.js': [
'coverage',
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"scripts": {
"karma-test": "node_modules/karma/bin/karma start js/karma.conf.js",
"karma-test:coverage": "node js/karma-coverage.js"
},
"devDependencies": {
"karma": "^6.3.19",
"karma-chrome-launcher": "^3.1.1",
Expand Down

0 comments on commit 7d44c54

Please sign in to comment.