Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Cypress so tests run & pass in a real browser #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
build/

### Node ###

# Logs
Expand Down
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
language: node_js
# default is apparently 0.10.48 for some reason O.O
node_js: '8.9'
node_js: '10.16.0'

# cache folder with Cypress binary (https://docs.cypress.io/guides/guides/continuous-integration.html#Travis)
cache:
directories:
- ~/.cache
4 changes: 4 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"video": false,
"modifyObstructiveCode": false
}
8 changes: 8 additions & 0 deletions cypress/integration/browserify.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Physijs = require('../../browserify.js')

describe('browserify', () => {
it('should create a scene', () => {
const scene = new Physijs.Scene()
expect(scene.type).to.eq('Scene')
})
})
8 changes: 8 additions & 0 deletions cypress/integration/webpack.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Physijs = require('../../webpack.js')

describe('webpack', () => {
it('should create a scene', () => {
const scene = new Physijs.Scene()
expect(scene.type).to.eq('Scene')
})
})
34 changes: 34 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const browserify = require('@cypress/browserify-preprocessor')
const webpack = require('@cypress/webpack-preprocessor')

const ammoPath = require.resolve('../../physijs/vendor/ammo.js')

const bProcess = browserify({
browserifyOptions: {
// don't parse ammo
noParse: [ammoPath],
// override the preprocessor default (which runs babelify)
transform: []
}
})

const wProcess = webpack({
webpackOptions: {
// fast builds, build is only used for testing purposes
mode: 'development',
// don't parse ammo
module: {
noParse: ammoPath,
}
}
})

module.exports = (on) => {
// process webpack test w/ webpack and browserify test w/ browserify
on('file:preprocessor', (file) => {
if (file.filePath.includes('webpack.spec.js')) {
return wProcess(file)
}
return bProcess(file)
})
}
Empty file added cypress/support/commands.js
Empty file.
6 changes: 6 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require('./commands')

// nothing to screenshot here
Cypress.Screenshot.defaults({
screenshotOnRunFailure: false
})
Loading