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

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

Merged
merged 1 commit into from Nov 29, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

test(cypress): Add initial Cypress smoke test

  • Loading branch information...
markdalgleish committed Nov 29, 2018
commit 32a3bd0fca5938932a77dba020e2071449cab26e
@@ -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 =>

This comment has been minimized.

Copy link
@jackhurley23

jackhurley23 Nov 29, 2018

Contributor

Nice 🎉

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"
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.