Skip to content

Commit

Permalink
fix: Added jest and jest config
Browse files Browse the repository at this point in the history
Added Jest for unit testing as Cypress doesn't support
good Unit testing yet. All Cypress test except the Peer
Connection are now on localhost to improve CI testing.
Small decrease in percentage as pnp.js is lesser tested
in e2e tests now.
  • Loading branch information
BKristenssonAlfsson committed May 31, 2020
1 parent e2bbe7e commit 33b853c
Show file tree
Hide file tree
Showing 8 changed files with 4,936 additions and 1,951 deletions.
18 changes: 17 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
module.exports = {
root: true,

env: {
node: true
},

extends: [
'plugin:vue/strongly-recommended',
'@vue/standard'
],

rules: {
'no-console': 'off',
'no-debugger': 'off'
},

parserOptions: {
parser: 'babel-eslint'
}
},

overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)'
],
env: {
jest: true
}
}
]
}
8 changes: 2 additions & 6 deletions cypress/integration/ambianic-tests/navbar.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/**
* This test will only work while the EC2 machines are running.
*/

/// <reference types="cypress" />

context('Check Navbar Items', () => {
before(() => {
cy.visit('http://18.219.76.94')
cy.get('[data-cy=settings]').click()
cy.visit('http://localhost:8080')
cy.get('[data-cy=timeline]').click()
})

it('Should have a search bar', () => {
Expand Down
8 changes: 2 additions & 6 deletions cypress/integration/ambianic-tests/settings.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/**
* This test will only work while the EC2 machines are running.
*/

/// <reference types="cypress" />

context('RemoteConnections', () => {
context('Settings', () => {
before(() => {
cy.visit('http://18.219.76.94')
cy.visit('http://localhost:8080')
cy.get('[data-cy=settings]').click()
})

Expand Down
36 changes: 18 additions & 18 deletions cypress/integration/ambianic-tests/timeline.spec.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
/**
* This test will only work while the EC2 machines are running.
*/

/// <reference types="cypress" />

context('RemoteConnections', () => {
beforeEach(() => {
cy.visit('http://18.219.76.94')
context('Timeline', () => {
before(() => {
cy.visit('http://localhost:8080')
cy.get('[data-cy=timeline]').click()
})

it('Should browse to timeline', () => {
cy.get('[data-cy=timeline]').click()

cy.url().should('include', '/timeline')
})

it('Should render connection card', () => {
cy.get('[data-cy=timeline]').click()

cy.get('.mx-auto').contains('Connecting to Ambianic Edge device...')
cy.get('[data-cy=connectioncard]').contains('Connecting to Ambianic Edge device...')
})

/**
* This will be removed once we have decided on the flow
* for future layout/flow in UI / Edge connection
*/
it('Should browse to edgeconnect', () => {
cy.get('[data-cy=timeline]').click()

cy.wait(500)

Expand All @@ -35,11 +27,19 @@ context('RemoteConnections', () => {
cy.url().should('include', '/edge-connect')
})

it('Should generate no results in timeline', () => {
cy.get('[data-cy=timeline]').click()
// Try to get this to work once we have mock data

cy.wait(5000)
// it('Get timeline data', () => {
// cy.get('[data-cy=timelinedata]').then(($result) => {
// console.log($result)
// })
// })

cy.get('.infinite-status-prompt').contains('No results :(')
})
// it('Should generate no results in timeline', () => {
// cy.get('[data-cy=timeline]').click()

// cy.wait(5000)

// cy.get('.infinite-status-prompt').contains('No results :(')
// })
})
25 changes: 25 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
verbose: true,
moduleNameMapper: {
"module_name_(.*)": "<rootDir>/src/$1"
},
moduleFileExtensions: [
"js",
"json",
"vue"
],
transform: {
".*\\.(vue)$": "vue-jest",
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
},
collectCoverage: true,
collectCoverageFrom: [
"src\\*.{js,vue}",
"!**/node_modules/**"
],
coverageReporters: [
"html",
"text-summary"
],
preset: '@vue/cli-plugin-unit-jest'
}
Loading

0 comments on commit 33b853c

Please sign in to comment.