Giter VIP home page Giter VIP logo

gemini-react's Introduction

gemini-react

Build Status codecov

gemini plugin for simplifying visual regression testing on React + webpack stack.

WARNING: Right now plugin is pretty much at the proof-of-concept stage, do not use in production.

Configuring

  1. Install plugin using npm:

    npm install gemini-react
    
  2. Enable it in your gemini config file:

system:
  plugins:
    react:
      webpackConfig: <PATH>
      hostname: <HOST NAME>
      port: <PORT NUMBER> ```

Options

  • webpackConfig (required) – path to your webpack config. Plugin will use loaders from this file to build test pages.

  • listenHost (default: 127.0.0.1) - hostname to run reference test server on.

  • port (default: 5432) - port to run test server on.

  • replaceRootUrl (default: true) - automatically sets rootUrl of every browser to http://<listenHost>:<port>. Set to false if rootUrl should be something else.

  • staticRoot - directory, which contains your static asset files. Will be mounted by your test server automatically.

  • cssFiles - list of CSS files to include in every test page. Requires staticRoot option to be set.

  • jsModules - list of additional js modules to include in the test pages. Relative to project root. This modules will be included into your client bundle before the rest files.

  • customizeServer - path to js file, used to customize the express server. The file should have a single export, which is function of (app, express).

    Example:

    module.exports = function(app, express) {
      app.use(function myMiddleware(req, res, next) {
          ...
      });
    }
  • webpackLazyMode - switches webpack dev middleware to lazy mode, which means javascript will be recompiled on each request.

Writing the tests

Use geminiReact variable instead of gemini and render(<ReactComponent />) instead of setUrl and setCaptureElements. The rest is the same as vanilla gemini:

const MyComponent = require('./path/to/my/component');
geminiReact.suite('my react test', suite => {
    suite.render(<MyComponent prop="value" />)
        .capture('initial');
});

TIP: To use JSX in your tests, you might need gemini-babel plugin.

You don't need to create the reference pages or run the server, plugin will do everything for you.

If you want to interact with rendered component, use this.renderedComponent inside your test:

suite.capture('clicked', function(actions) {
    actions.click(this.renderedComponent);
});

If you have any test-specific stylesheets, you can include them into the test page by calling suite.includeCss:

suite.includeCss('/my-component.css');

By default, geminiReact will capture rendered at mounting point element. If you want to add some extra elements, use setExtraCaptureElements:

suite.setExtraCaptureElements(['.popup']);

Viewing the example page

If you want to view example pages without actually running the tests, you can use gemini-react-server binary, provided by this package:

./node_modules/.bin/gemini-react-server

It will run the server on the host and port, specified in plugin configuration in .gemini.yml.

The url of each example is a series of ulr-encoded suite names. For example, this suite:

geminiReact.suite('parent', () => {
    geminiReact.suite('child', () => {
       ...
    });
})

will be served at http://HOST:PORT/parent/child url.

gemini-react's People

Contributors

danez avatar greenkeeper[bot] avatar sevinf avatar tx44 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gemini-react's Issues

Explore the ways of making the plugin less webpack-dependent

Right now plugin expects that webpack is used. Using other bundlers is not possible, and non-js imports need to be stubbed to avoid the errors inside express server.
One possible way to solve this is making bundler customizable.

Another one is removing bundling from project at all and expect tests to be built before gemini is executed. Runtime wrapping on client and server can be replaced by AOT compiltion in this case.

Plugin runs tests before build is finished?

I write tests with gemini-react.
When the number of tests grows, I need to increase httpTimeout in gemini config because of timeout errors.
It seems that first requests to gemini-react server runs before webpack build is finished.
Can it be possible?
If so, can it be fixed?
If so, can you give a direction, where to start hacking?

An in-range update of debug is breaking the build 🚨

Version 3.2.0 of debug was just published.

Branch Build failing 🚨
Dependency debug
Current Version 3.1.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

debug is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes 3.2.0

A long-awaited release to debug is available now: 3.2.0.

Due to the delay in release and the number of changes made (including bumping dependencies in order to mitigate vulnerabilities), it is highly recommended maintainers update to the latest package version and test thoroughly.


Minor Changes

Patches

Credits

Huge thanks to @DanielRuf, @EirikBirkeland, @KyleStay, @Qix-, @abenhamdine, @alexey-pelykh, @DiegoRBaquero, @febbraro, @kwolfy, and @TooTallNate for their help!

Commits

The new version differs by 25 commits.

There are 25 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Provide a list of TODOs

The project has a warning in README:

Right now plugin is pretty much at the proof-of-concept stage, do not use in production.

Could you please add in README a list of things to do (or create issues with some tag) before release 1.0?

An in-range update of mocha is breaking the build 🚨

Version 3.5.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.4.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… dependency-ci Dependencies checked Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes free-as-in-freezing

3.5.0 / 2017-07-31

πŸ“° News

  • Mocha now has a code of conduct (thanks @kungapal!).
  • Old issues and PRs are now being marked "stale" by Probot's "Stale" plugin. If an issue is marked as such, and you would like to see it remain open, simply add a new comment to the ticket or PR.
  • WARNING: Support for non-ES5-compliant environments will be dropped starting with version 4.0.0 of Mocha!

πŸ”’ Security Fixes

πŸŽ‰ Enhancements

  • #2696: Add --forbid-only and --forbid-pending flags. Use these in CI or hooks to ensure tests aren't accidentally being skipped! (@charlierudolph)
  • #2813: Support Node.js 8's --napi-modules flag (@jupp0r)

πŸ”© Other

Commits

The new version differs by 34 commits.

  • 82d879f Release v3.5.0
  • bf687ce update mocha.js for v3.5.0
  • ec73c9a update date for release of v3.5.0 in CHANGELOG [ci skip]
  • 1ba2cfc update CHANGELOG.md for v3.5.0 [ci skip]
  • 065e14e remove custom install script from travis (no longer needed)
  • 4e87046 update karma-sauce-launcher URL for npm@5
  • 6886ccc increase timeout for slow-grepping test
  • 2408d90 Make dependencies use older version of readable-stream to work around incompatibilities introduced by 2.3.0 on June 19th
  • 68a1466 Try not clearing the env for debug in the integration test and see if that fixes Node 0.10 on AppVeyor; if need be, some other fix/workaround can be applied to handle whatever was up with debug without causing this issue
  • 958fbb4 Update new tests to work in browser per test hierarchy reorganization
  • 1df7c94 Merge pull request #2704 from seppevs/increase_test_coverage_of_mocha_js
  • 1f270cd Stop timing out (#2889)
  • 27c7496 upgrade to [email protected]; closes #2859 (#2860)
  • 50fc47d fix CI; closes #2867 (#2868)
  • 1b1377c Add test for ignoreLeaks and fix descriptions

There are 34 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of rimraf is breaking the build 🚨

Version 2.6.2 of rimraf just got published.

Branch Build failing 🚨
Dependency rimraf
Current Version 2.6.1
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

rimraf is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… dependency-ci Dependencies checked Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 2 commits.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of react is breaking the build 🚨

Version 15.6.2 of react just got published.

Branch Build failing 🚨
Dependency react
Current Version 15.6.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As react is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… dependency-ci Dependencies checked Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Critical error on gemini update

Hi!

Thanks for your plugin! I know, it's not production-ready, but I'm interested in such functionality and I checked if I'll be able to use it with popular RSK

It seems that there is an error in gemini-babel or gemini-react:

$ ./node_modules/.bin/gemini update
Critical error:
SyntaxError: Unexpected token import
/Users/savin/PhpstormProjects/react-starter-kit/tools/webpack.config.js:10
import path from 'path';
^^^^^^

You can easily reproduce it using this code

An in-range update of debug is breaking the build 🚨

Version 2.4.0 of debug just got published.

Branch Build failing 🚨
Dependency debug
Current Version 2.3.3
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As debug is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • βœ… dependency-ci Dependencies checked Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 7 commits .

  • b82d4e6 release 2.4.0
  • 41002f1 Update bower.json (#342)
  • e58d54b Node: configurable util.inspect() options (#327)
  • 00f3046 Node: %O (big O) pretty-prints the object (#322)
  • bd9faa1 allow colours in workers (#335)
  • 501521f Use same color for same namespace. (#338)
  • e2a1955 Revert "handle regex special characters"

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

`geminiReact is not defined` with gemini update to v4.11.0

gemini v4.11.0 release is breaking this plugin:

Critical error:
ReferenceError: geminiReact is not defined
    at Object.<anonymous> (/Users/teryaew/Projects/common/gemini-react-example/gemini/button.gemini.js:3:1)
    at Module._compile (module.js:556:32)
    at loader (/Users/teryaew/Projects/common/gemini-react-example/node_modules/babel-register/lib/node.js:146:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/teryaew/Projects/common/gemini-react-example/node_modules/babel-register/lib/node.js:156:7)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.exports.requireWithNoCache (/Users/teryaew/Projects/common/gemini-react-example/node_modules/gemini/lib/utils.js:5:12)
    at sets.forEachFile (/Users/teryaew/Projects/common/gemini-react-example/node_modules/gemini/lib/test-reader/index.js:22:15)
    at _getFiles.forEach (/Users/teryaew/Projects/common/gemini-react-example/node_modules/gemini/lib/test-reader/set-collection.js:65:44)
    at Array.forEach (native)
    at SetCollection.forEachFile (/Users/teryaew/Projects/common/gemini-react-example/node_modules/gemini/lib/test-reader/set-collection.js:65:26)
    at loadSuites (/Users/teryaew/Projects/common/gemini-react-example/node_modules/gemini/lib/test-reader/index.js:18:10)
    at q.all.spread (/Users/teryaew/Projects/common/gemini-react-example/node_modules/gemini/lib/test-reader/index.js:49:16)
ERROR: "gemini:test" exited with 1.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected πŸ€–


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-config-gemini-testing is breaking the build 🚨

Version 2.4.1 of eslint-config-gemini-testing just got published.

Branch Build failing 🚨
Dependency eslint-config-gemini-testing
Current Version 2.4.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint-config-gemini-testing is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… dependency-ci Dependencies checked Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 4 commits.

  • 2189eac 2.4.1
  • 07fa45e Merge pull request #14 from gemini-testing/fix/no-multiple-empty-lines
  • 5cfac7a fix: 'no-multiple-empty-lines' rule
  • ee239bf chore: add 'npm' and 'git' ignore files

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of react-dom is breaking the build 🚨

Version 15.6.2 of react-dom just got published.

Branch Build failing 🚨
Dependency react-dom
Current Version 15.6.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As react-dom is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… dependency-ci Dependencies checked Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of sinon is breaking the build 🚨

Version 2.3.7 of sinon just got published.

Branch Build failing 🚨
Dependency sinon
Current Version 2.3.6
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As sinon is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… dependency-ci Dependencies checked Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes Fix #1476
  • Fix #1476: spy.withArgs(args...).firstCall is broken
Commits

The new version differs by 13 commits.

  • 9365d49 Update docs/changelog.md and set new release id in docs/_config.yml
  • 7399b99 Add release documentation for v2.3.7
  • 21b4588 2.3.7
  • 169ac9d Update Changelog.txt and AUTHORS for new release
  • 1108117 Merge pull request #1480 from fearphage/lint-staged
  • 9ecd56a moved from dependencies to dev dependencies [ci skip]
  • 0a85f21 improved linting for staged files [ci skip]
  • 079925b Merge pull request #1478 from takasmiley/issues/#1476
  • 40efa6f Cleanup a few test codes
  • 1ff2b9b Add spy.getCall tests with combination of withArgs arguments
  • c280916 Fix #1476: spy.withArgs(args...).firstCall is broken
  • 8ad2ed7 Merge pull request #1477 from mroderick/add-documentation-for-getcalls
  • fea23b0 Add missing documentation for spy.getCalls()

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Provide possibility to wrap components before render

It's a feature request.
It would be great to have possibility to provide a wrapper component for all components in all tests.

Consider this example. I need App with context around all components that use css modules - literally all components that I want to test.

I can help with implementation, if you think the idea is ok.

Render the page takes a long time

Hi there! Thanks for the great plugin!

I have performance issue. My screenshots tests take a very long time. I started digging it and I found out the reason. The plugin has middleware that renders HTML pages for test. It has a call webpackStats.toJson() that takes in my case around 1s.

We need only assetsByChunkName information in stats for render html. webpackStats.toJson(options) provide passing settings: docs. With this paramswebpackStats.toJson({ chunk: false, modules: false }) the call takes no time.

I've created PR with this changes

Example doesn't work: Could not find element

Hello!

Trying your plugin and faced trouble. My test file looks like:

import React from 'react';

geminiReact.suite('my react test', suite => {
    suite.render(<div>Hello world</div>).capture('initial');
});

And problem after running update:

node_modules/.bin/gemini update
(node:60437) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
✘ my react test initial [chrome]
Could not find element with css selector specified in setCaptureElements: [data-gemini-react] > *
Total: 1 Passed: 0 Failed: 1 Skipped: 0 Retries: 0

Browser opened blank page and closed it immediately.
I assume, that component not mounted at all :(
What can be wrong? Webpack config or missed babel-presets?

require(*.css) in imported component

Hi, @SevInf, and thanx for this plugin.

I'm trying to integrate gemini with one ui library based on React and stuck with some issues. One I corrected in this PR. Another question is about styles requirement inside imported components in gemini tests. How to deal with this?

I created example repo for this case: https://github.com/teryaew/gemini-react-example
Remove babel-plugin-transform-require-ignore line in .babelrc and Babel will crash testing:

Critical error:
SyntaxError: /Users/teryaew/Projects/common/gemini-react-example/src/button/button.css: Unexpected token (1:0)
> 1 | .button {
    | ^

Also there is issue with importing React for every gemini test or using babel-plugin-react-require. You can reproduce it in repo too. Maybe there some solution other than that?

P.S.: My node -v is v6.5.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.