Skip to content
Permalink
Browse files

test(cypress): Add initial Cypress smoke test (#28)

  • Loading branch information...
markdalgleish committed Nov 29, 2018
1 parent a1a3b52 commit 406f2aa73523b723bab90364e7193f15ca2dedcf
@@ -1 +1,3 @@
cypress/plugins/
cypress/fixtures/
node_modules
@@ -1,3 +1,8 @@
dist/
cypress/videos/
cypress/screenshots/
cypress/plugins/
cypress/fixtures/
node_modules/
package-lock.json
*.log
@@ -0,0 +1 @@
{}
@@ -0,0 +1,12 @@
{
"plugins": [
"cypress"
],
"extends": [
"seek",
"plugin:cypress/recommended"
],
"env": {
"cypress/globals": true
}
}
@@ -0,0 +1,11 @@
import { typeCode, assertFrameContains } from '../support/utils';

describe('Smoke test', () => {
it('works', () => {
typeCode('<Foo />');
assertFrameContains('Foo');

typeCode('<Bar />');
assertFrameContains('Bar');
});
});
@@ -0,0 +1,4 @@
import React from 'react';

export const Foo = () => <div>Foo</div>;
export const Bar = () => <div>Bar</div>;
@@ -0,0 +1,5 @@
module.exports = {
components: './components',
outputPath: './dist',
openBrowser: false
};
@@ -0,0 +1,4 @@
beforeEach(() => {
cy.visit('http://localhost:9000');
indexedDB.deleteDatabase('playroom');
});
@@ -0,0 +1,16 @@
export const typeCode = code =>
cy
.get('.CodeMirror')
.click()
.focused()
.clear({ force: true })
.type(code, { force: true });

export const assertFrameContains = async text => {
const iframe = await cy.get('iframe').first();

return iframe
.contents()
.find('body')
.contains(text);
};
@@ -5,8 +5,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');

const playroomPath = path.resolve(__dirname, '..');
const examplesPath = path.resolve(playroomPath, 'examples');
const localNodeModulesPath = path.resolve(playroomPath, 'node_modules');
const includePaths = [
path.resolve(playroomPath, 'lib'),
path.resolve(playroomPath, 'src')
];
const makeDefaultWebpackConfig = require('./makeDefaultWebpackConfig');

module.exports = (playroomConfig, options) => {
@@ -37,8 +39,7 @@ module.exports = (playroomConfig, options) => {
rules: [
{
test: /\.js$/,
include: [playroomPath],
exclude: [examplesPath, localNodeModulesPath],
include: includePaths,
use: {
loader: require.resolve('babel-loader'),
options: {
@@ -54,8 +55,7 @@ module.exports = (playroomConfig, options) => {
},
{
test: /\.less$/,
include: [playroomPath],
exclude: [examplesPath, localNodeModulesPath],
include: includePaths,
use: [
{
loader: require.resolve('style-loader'),
@@ -7,11 +7,16 @@
"playroom": "bin/cli.js"
},
"scripts": {
"test": "npm run cypress",
"cypress": "start-server-and-test cypress:prepare http://localhost:9000 cypress:run",
"cypress:dev": "start-server-and-test cypress:prepare http://localhost:9000 cypress:open",
"cypress:prepare": "./bin/cli.js start --config cypress/projects/basic/playroom.config.js",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"commit": "git-cz",
"lint": "eslint .",
"format": "prettier --config ./.prettierrc --write '**/*.{js,md,less}'",
"semantic-release": "semantic-release",
"test": "echo \"Error: no test specified\""
"semantic-release": "semantic-release"
},
"husky": {
"hooks": {
@@ -89,13 +94,16 @@
"@commitlint/cli": "^7.2.1",
"commitizen": "^3.0.4",
"commitlint-config-seek": "^1.0.0",
"cypress": "^3.1.2",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^5.8.0",
"eslint-config-seek": "^3.2.1",
"eslint-plugin-cypress": "^2.1.2",
"extract-text-webpack-plugin": "^3.0.2",
"husky": "^1.1.3",
"lint-staged": "^8.0.4",
"prettier": "^1.15.1",
"semantic-release": "^15.10.8"
"semantic-release": "^15.10.8",
"start-server-and-test": "^1.7.11"
}
}

0 comments on commit 406f2aa

Please sign in to comment.
You can’t perform that action at this time.