Skip to content

Commit

Permalink
Merge pull request #2649 from GMOD/embedded_tests
Browse files Browse the repository at this point in the history
Add Cypress test of package that uses embedded components
  • Loading branch information
rbuels committed Jan 19, 2022
2 parents becbb92 + c4ba67b commit e31cb62
Show file tree
Hide file tree
Showing 42 changed files with 855 additions and 17 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@
"rules": {
"import/no-extraneous-dependencies": "off"
}
},
{
"files": ["**/component_test/**"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"project": "./component_test/tsconfig.json"
}
},
{
"files": ["**/component_test/cypress/**"],
"extends": ["plugin:cypress/recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"project": "./component_test/cypress/tsconfig.json"
}
}
]
}
8 changes: 8 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ jobs:
run: yarn build
- name: Test build
run: BUILT_TESTS=1 yarn built-test-ci
- name: Test embedded
# CI=false since we have a warning that gets treated as an error under CI
# Warning is: "Critical dependency: the request of a dependency is an expression"
run: |
yarn
CI=false yarn build
yarn test:e2e
working-directory: component_test

buildjbrowseweb:
name: Build only jbrowse-web and upload to s3 on node 14 and ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions component_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
packed/
/node_modules
/coverage
/build
yarn.lock
cypress/screenshots/
cypress/videos/
1 change: 1 addition & 0 deletions component_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Demo of `@jbrowse/react-linear-genome-view`
5 changes: 5 additions & 0 deletions component_test/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"baseUrl": "http://localhost:5000",
"chromeWebSecurity": false,
"video": false
}
13 changes: 13 additions & 0 deletions component_test/cypress/integration/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('JBrowse embedded view', () => {
it('page loads', () => {
cy.visit('/')
cy.contains('JBrowse 2 React Linear Genome View Demo')
})
it('track loads', () => {
cy.visit('/')
cy.findByTestId('Blockset-pileup').findByTestId(
'prerendered_canvas_{GRCh38}10:29,838,733..29,838,818-0',
{ timeout: 10000 },
)
})
})
22 changes: 22 additions & 0 deletions component_test/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
27 changes: 27 additions & 0 deletions component_test/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ***********************************************
// 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) => { ... })

import '@testing-library/cypress/add-commands'
20 changes: 20 additions & 0 deletions component_test/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.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')
10 changes: 10 additions & 0 deletions component_test/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "@testing-library/cypress"],
"allowJs": true,
"outDir": "dist"
},
"include": ["./**/*"]
}
64 changes: 64 additions & 0 deletions component_test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "jbrowse-react-linear-genome-view-demo",
"version": "0.1.0",
"private": true,
"dependencies": {
"@jbrowse/react-linear-genome-view": "1.5.8",
"@testing-library/cypress": "^8.0.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/cypress": "^1.1.3",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"cypress": "^9.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"fontsource-roboto": "^4.0.0",
"prettier": "^2.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"serve": "^13.0.2",
"start-server-and-test": "^1.14.0",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
"resolutions": {
"@jbrowse/core": "file:./packed/jbrowse-core.tgz",
"@jbrowse/plugin-alignments": "file:./packed/jbrowse-plugin-alignments.tgz",
"@jbrowse/plugin-bed": "file:./packed/jbrowse-plugin-bed.tgz",
"@jbrowse/plugin-circular-view": "file:./packed/jbrowse-plugin-circular-view.tgz",
"@jbrowse/plugin-config": "file:./packed/jbrowse-plugin-config.tgz",
"@jbrowse/plugin-data-management": "file:./packed/jbrowse-plugin-data-management.tgz",
"@jbrowse/plugin-gff3": "file:./packed/jbrowse-plugin-gff3.tgz",
"@jbrowse/plugin-linear-genome-view": "file:./packed/jbrowse-plugin-linear-genome-view.tgz",
"@jbrowse/plugin-sequence": "file:./packed/jbrowse-plugin-sequence.tgz",
"@jbrowse/plugin-svg": "file:./packed/jbrowse-plugin-svg.tgz",
"@jbrowse/plugin-trix": "file:./packed/jbrowse-plugin-trix.tgz",
"@jbrowse/plugin-variants": "file:./packed/jbrowse-plugin-variants.tgz",
"@jbrowse/plugin-wiggle": "file:./packed/jbrowse-plugin-wiggle.tgz",
"@jbrowse/react-linear-genome-view": "file:./packed/jbrowse-react-linear-genome-view.tgz"
},
"scripts": {
"start": "react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"test:e2e": "start-test 'serve --listen 5000 build/' 5000 'cypress run --headless --browser chrome'"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Loading

0 comments on commit e31cb62

Please sign in to comment.