Test scaffold for analytic plugins.
- Verify that plugins load the analytics provider library
- Verify that
.page
calls map and call to the underlying window global - Verify that
.track
calls map and call to the underlying window global - Verify that
.identify
calls map and call to the underlying window global
For example, the @analytics/google-analytics
plugin should load google analytics and track a page view
import Analytics from 'analytics'
import googleAnalytics from '@analytics/google-analytics'
/* initialize analytics */
const analytics = Analytics({
app: 'analytics-demo',
plugins: [
// π this should load google analytics onto the page
googleAnalytics({
trackingId: 'UA-126647663-3'
})
]
})
// π this fire a page view to google analytics
analytics.page()
- This repo is structured similar to how other "Monorepos" work.
- Each
example project
has it's own Cypress configuration, tests, backend and frontend assets. - Each of these
example projects
share a single "root" Cypress that is installed in the rootnode_modules
folder. - This structure looks different from normal projects, but its the easiest way to manage multiple projects without installing Cypress independently for each one.
## install all dependencies
npm install
cd ./examples/testing-dom__drag-drop
# start local server
npm start &
# and open Cypress GUI
npm run cypress:open
Same as running Cypress GUI but with cypress run
command (and any CLI arguments)
cd ./examples/testing-dom__drag-drop
# start local server
npm start &
# run Cypress tests headlessly
npm run cypress:run
### runs all example projects in specific browser
### similar to cypress run --browser <name>
npm run cypress:run -- --browser chrome
### sends test results, videos, screenshots
### to Cypress dashboard
npm run cypress:run -- --record
See Development.md
Might need to expose internals https://stackoverflow.com/questions/42508142/sinon-basic-use-with-internal-functions https://stackoverflow.com/questions/52332152/how-to-mock-an-inner-function-in-sinon https://stackoverflow.com/questions/34575750/how-to-stub-exported-function-in-es6
might need proxy require sinonjs/sinon#562 (comment) No extra dep solution 3 https://medium.com/@minaluke/how-to-stub-spy-a-default-exported-function-a2dc1b580a6b cypress-io/cypress#2597 (comment)
- https://github.com/etcaterva/eas-frontend/blob/b484bc393e9c1b784d3c3163c4e4210978a52c04/cypress/integration/FacebookRaffle_spec.js#L9
- https://github.com/etcaterva/eas-frontend/blob/b484bc393e9c1b784d3c3163c4e4210978a52c04/cypress/support/commands.js#L61-L65
- spy action https://github.com/shopgate/theme-gmd/blob/95a9ea746d558103aaaa47dcd2f84d009e5634c7/e2e/integration/functional/CartPage.js#L38 + https://github.com/shopgate/pwa/blob/61b5656f1c1c854e3848c2b9e71e9c3d48ba7894/utils/e2e/support/commands.js#L32-L69