-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cypress testing base setup including - eslint support - configuration for e2e, component and unit tests - ignoring relevant files - basic e2e test home_page.cy.js - new webpack config for component tests - remove of duplicate line from .gitignore Component tests should be written in the component e.g. 'MyComponent.cy.js' for 'MyComponent.vue' Unit tests for js source files should be in a separate '__tests__' folder and be named similar e.g. '__tests__/utils.cy.js' for 'utils.js' e2e tests should go to 'cypress/e2e/test-name.cy.js'
- Loading branch information
1 parent
9865f2c
commit 10631c1
Showing
12 changed files
with
1,725 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
'use strict' | ||
const { resolveRoot, styleLoaders} = require('./utils') | ||
const config = require('../config') | ||
const vueLoaderConfig = require('./vue-loader.conf') | ||
const webpack = require('webpack') | ||
|
||
|
||
const createLintingRule = () => ({ | ||
test: /\.(js|vue)$/, | ||
loader: 'eslint-loader', | ||
enforce: 'pre', | ||
include: [resolveRoot('src'), resolveRoot('test')], | ||
exclude: [resolveRoot('tests/integration/mockups')], | ||
options: { | ||
formatter: require('eslint-friendly-formatter'), | ||
emitWarning: !config.dev.showEslintErrorsInOverlay | ||
} | ||
}) | ||
|
||
module.exports = { | ||
plugins: [ | ||
// fix "process is not defined" error: | ||
new webpack.ProvidePlugin({ | ||
process: 'process/browser', | ||
}) | ||
], | ||
context: resolveRoot(), | ||
entry: { | ||
app: './src/main.js' | ||
}, | ||
output: { | ||
path: config.build.assetsRoot, | ||
filename: '[name].js', | ||
assetModuleFilename: '[base]', | ||
publicPath: '/' | ||
}, | ||
resolve: { | ||
alias: { | ||
'@': resolveRoot('src'), | ||
'vue$': 'vue/dist/vue.esm.js' | ||
}, | ||
extensions: ['.vue', '.js', '.json'], | ||
fallback: { | ||
timers: require.resolve('timers-browserify'), | ||
stream: require.resolve('stream-browserify') | ||
} | ||
}, | ||
module: { | ||
rules: [ | ||
...(config.dev.useEslint ? [createLintingRule()] : []), | ||
{ | ||
test: /\.vue$/, | ||
loader: 'vue-loader', | ||
options: vueLoaderConfig | ||
}, | ||
{ | ||
test: /\.js$/, | ||
loader: 'babel-loader', | ||
include: [ | ||
resolveRoot('src/'), | ||
resolveRoot('test/'), | ||
resolveRoot('node_modules/webpack-dev-server/client/') | ||
], | ||
options: { | ||
plugins: [ '@babel/plugin-proposal-object-rest-spread' ] | ||
} | ||
},{ | ||
test: /\.(woff|woff2|eot|ttf|otf|png|svg|jpg|jpeg|gif|ico)$/i, | ||
type: 'asset' | ||
},{ | ||
test: /\.(geojson|kml|gpx|txt)$/i, | ||
type: 'asset/source', | ||
}, | ||
...styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const { defineConfig } = require("cypress"); | ||
const config = require('./config'); | ||
const webpackPreprocessor = require('@cypress/webpack-preprocessor') | ||
|
||
module.exports = defineConfig({ | ||
projectId: '2npvgh', | ||
video: false, | ||
e2e: { | ||
specPattern: [ | ||
"cypress/e2e/*.{cy,spec}.{js,jsx,ts,tsx}", | ||
"src/**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}" | ||
], | ||
baseUrl: 'http://localhost:8080', | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
const options = { | ||
// send in the options from your webpack.config.js, so it works the same | ||
// as your app's code | ||
webpackOptions: require('./build/webpack.base.conf'), | ||
watchOptions: {}, | ||
} | ||
|
||
on('file:preprocessor', webpackPreprocessor(options)) | ||
}, | ||
}, | ||
component: { | ||
devServer: { | ||
framework: 'vue', | ||
bundler: 'webpack', | ||
// optionally pass in webpack config | ||
webpackConfig: require('./build/webpack.cypress.conf'), | ||
}, | ||
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}', | ||
excludeSpecPattern: "src/**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}" | ||
}, | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// <reference types="cypress" /> | ||
import defaultMapSettings from '../../src/config/default-map-settings' | ||
import appConfig from '../../src/config/app-config' | ||
|
||
describe('Ors map client', () => { | ||
it('successfully loads', () => { | ||
cy.visit('/') | ||
let coords = defaultMapSettings.mapCenter | ||
cy.url().should('contain', coords.lat).should('contain', coords.lng). | ||
should('contain', appConfig.initialZoomLevel.toString()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-us"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
<title>Components App</title> | ||
</head> | ||
<body> | ||
<div data-cy-root></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// *********************************************************** | ||
// This example support/component.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') | ||
|
||
import { mount } from 'cypress/vue2' | ||
|
||
Cypress.Commands.add('mount', mount) | ||
|
||
// Example use: | ||
// cy.mount(MyComponent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
Oops, something went wrong.