Skip to content

Commit 54467a9

Browse files
committed
add example with just unit test code coverage
1 parent 89d4ab5 commit 54467a9

File tree

8 files changed

+48
-0
lines changed

8 files changed

+48
-0
lines changed

examples/unit-tests-js/.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["istanbul"]
3+
}

examples/unit-tests-js/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# example: unit-tests-js
2+
3+
Examples that only run unit tests written using JavaScript

examples/unit-tests-js/cypress.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"fixturesFolder": false
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference types="cypress" />
2+
import { isObject, add } from '../../src/utils/misc'
3+
4+
describe('unit tests', () => {
5+
it('adds two numbers', () => {
6+
expect(add(2, 3)).to.equal(5)
7+
})
8+
9+
it('checks for object', () => {
10+
expect(isObject({}), '{}').to.be.true
11+
expect(isObject([]), '[]').to.be.true
12+
})
13+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = (on, config) => {
2+
require('../../../../task')(on, config)
3+
on('file:preprocessor', require('../../../../use-babelrc'))
4+
return config
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '../../../../support'

examples/unit-tests-js/package.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "example-unit-tests-js",
3+
"description": "Run unit tests written using JavaScript",
4+
"scripts": {
5+
"cy:open": "../../node_modules/.bin/cypress open"
6+
}
7+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Very simple check, returns true for arrays as well
3+
*/
4+
export function isObject(object) {
5+
return object != null && typeof object === 'object'
6+
}
7+
8+
/**
9+
* Adds two numbers together
10+
* @param {number} a
11+
* @param {number} b
12+
*/
13+
export const add = (a, b) => a + b

0 commit comments

Comments
 (0)