Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
test: install and e2e test library with cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
domkck committed Sep 21, 2020
1 parent 085b4b7 commit 2504b19
Show file tree
Hide file tree
Showing 20 changed files with 13,965 additions and 13 deletions.
20 changes: 19 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,35 @@ version: 2.1
executors:
node:
docker:
- image: cimg/node:12.13.0
- image: cypress/browsers:node12.13.0-chrome78-ff70
working_directory: ~/repo
resource_class: small
jobs:
build:
executor: node
steps:
- checkout

# Install deps and run unit tests
- run: npm ci
- run: npm test

# Install the package as dependency and test that it works in a browser
- run: npm run build
- run:
command: npm ci
working_directory: e2e
- run:
command: npm run build
working_directory: e2e
- run:
command: npx http-server www
working_directory: e2e
background: true
- run:
command: npx cypress run
working_directory: e2e

workflows:
version: 2

Expand Down
10 changes: 6 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"env": {
"browser": true,
"browser": true,
"es2020": true,
"jest/globals": true
"jest/globals": true,
"cypress/globals": true
},
"plugins": ["jest"],
"plugins": ["jest", "cypress"],
"extends": [
"airbnb-base"
"airbnb-base",
"plugin:cypress/recommended"
],
"parserOptions": {
"ecmaVersion": 12,
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ dist

# TernJS port file
.tern-port

e2e/www/index.js
1 change: 1 addition & 0 deletions e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions e2e/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
20 changes: 20 additions & 0 deletions e2e/cypress/integration/library.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('@purple-dot/purple-dot-js', () => {
beforeEach(() => {
Cypress.on('window:before:load', (win) => {
cy.spy(win.console, 'error');
cy.spy(win.console, 'warn');
});

cy.visit('http://localhost:8080/');
});

it('Loads the Purple Dot SDK without warnings or errors', () => {
// https://on.cypress.io/window
cy.window().should('have.property', 'PurpleDot');

cy.window().then((win) => {
expect(win.console.error).to.have.callCount(0);
expect(win.console.warn).to.have.callCount(0);
});
});
});
21 changes: 21 additions & 0 deletions e2e/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <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}
*/
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions e2e/cypress/support/commands.js
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) => { ... })
20 changes: 20 additions & 0 deletions e2e/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')
Binary file added e2e/cypress/videos/library.spec.js.mp4
Binary file not shown.
3 changes: 3 additions & 0 deletions e2e/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { loadPurpleDot } from '@purple-dot/purple-dot-js';

loadPurpleDot().then(() => console.log('yay')).catch(err => console.error(err));
Loading

0 comments on commit 2504b19

Please sign in to comment.