GithubHelp home page GithubHelp logo

Better testing stack about history HOT 15 CLOSED

mjackson avatar mjackson commented on April 19, 2024
Better testing stack

from history.

Comments (15)

phated avatar phated commented on April 19, 2024

The library I was talking about on twitter - https://github.com/defunctzombie/zuul - it's my favorite runner, supporting mocha, jasmine, qunit frameworks, using the --electron flag will give you an electron instance to run your tests in and (I believe) gives you all of the stuff needed for your integration tests. Changing the location doesn't seem to affect the reporter, so that's a plus.

from history.

phated avatar phated commented on April 19, 2024

I don't think you should use intern, I've been following it since release and it was promising but it is very inflexible and have heard nothing but complaints from anyone that tries to use it.

from history.

phated avatar phated commented on April 19, 2024

Also, you can use your webpack config as part of zuul using https://www.npmjs.com/package/zuul-builder-webpack

from history.

dignifiedquire avatar dignifiedquire commented on April 19, 2024

I'm biased (current maintainer of Karma) but I will suggest to use Karma. There is an issue with changing urls when using Karma, which I'm currently investigating and hope to have a fix for soon (Ref: karma-runner/karma#1101) so after that you should be good to go

from history.

mjackson avatar mjackson commented on April 19, 2024

Thanks for the input @dignifiedquire. The reason I'm questioning if karma would be a good fit here is because it seems like karma doesn't want me to ever refresh the page, which is exactly the kind of thing we need to do every so often in a thorough test suite for a history lib. :)

For example, we currently have a beforeEach hook that does window.location.href = '/'. This hook is designed to give each test a clean history slate to start with. It would be better if we had a brand new session (i.e. browser tab) to work with in each test, but I'm currently working within the constraints of jsdom's "global" mode.

I guess my question for you is, is this the kind of thing that is within karma's expectations? Or has karma loaded code in the browser that will screw up the test if we do a page refresh?

@phated Thanks for the link to zuul (and bonus points for the Ghostbusters reference!). I'll add it to the list of possible candidates and give it a whirl.

from history.

ericclemmons avatar ericclemmons commented on April 19, 2024

@mjackson I started a similar search last week and Zuul made it to the top of my list as well, followed by Karma (mostly due to mindshare & my history with Angular).

Intern went through just the "R" of "R & D" before I decided to try out Zuul first.

I've subscribed to this thread so I can share my findings with the group as well. See you on the other side! :)

from history.

christian-bromann avatar christian-bromann commented on April 19, 2024

As the maintainer of WebdriverIO I can confirm that all of the above mentioned requirements would work since you can execute any arbitrary JS using execute or executeAsync. However I think you should go with zuul as it runs your tests directly in the browser. This makes them execute a lot faster and you don't work in two different environments (browser & node context) which makes it less confusing.

from history.

joeybaker avatar joeybaker commented on April 19, 2024

I'm not sure if you've already settled on zuul, but https://github.com/hughsk/smokestack has served me well – I'd recommend taking a look.

from history.

mjackson avatar mjackson commented on April 19, 2024

Thanks for the insight @christian-bromann. I still think that WebdriverIO could be a slightly better fit than zuul because it controls a client instance from the outside. It seems like this would be a huge benefit when testing a history lib because we can essentially start with a clean browser session with each test.

For example, if I pushState in an in-browser testing framework like karma/zuul I've already permanently modified certain aspects of window.history (like window.history.length) that cannot be undone unless I start a new browser session, so I'll end up with tests that leak state. For this reason, I'd like to do something like this (in mocha):

beforeEach(function (done) {
  client = webdriverio.remote(...); // Create a brand new client instance.
  client.init(done); // Start a new browser session.
});

afterEach(function (done) {
  client.end(done); // Destroy the browser session.
});

@christian-bromann Is there anything about creating and destroying multiple client instances in WebdriverIO that would prevent me from doing this? Or is this totally unnecessary for some reason?

from history.

mjackson avatar mjackson commented on April 19, 2024

@joeybaker Thanks for the recommendation, but unless I'm mistaken smokestack follows more or less the same process model as karma/zuul (runs everything in the same tab), right?

from history.

joeybaker avatar joeybaker commented on April 19, 2024

Yea, it does. :(

A possible solution would be to separate your tests into many files and launch a new smokestack instance for each file. That's basically what webdriver will do for you, but might make for a complicated test launch script.

from history.

christian-bromann avatar christian-bromann commented on April 19, 2024

It seems like this would be a huge benefit when testing a history lib because we can essentially start with a clean browser session with each test.

True.

Is there anything about creating and destroying multiple client instances in WebdriverIO that would prevent me from doing this? Or is this totally unnecessary for some reason?

You should use the wdio runner. Like in protractor you define a set of capabilities + the test spec that the capability should test. You should also be able to recreate the Selenium session during a wdio test run.

from history.

mjackson avatar mjackson commented on April 19, 2024

Man, spent most of today trying to put together a branch that uses WebdriverIO for testing, but it's a lot of work. Basically, the flow ended up like this:

  1. Install & boot selenium
  2. Bundle my library + tests to a test/bundle.js file
  3. Boot an HTTP server that serves test/index.html. test/index.html has a <script> tag that includes test/bundle.js
  4. From my test suite, use WebdriverIO's execute method to execute test methods on the client

But it feels clunky. Maybe a single process suite is the way to go...

from history.

joeybaker avatar joeybaker commented on April 19, 2024

Whatever works is good, but for what it's worth, the reason I suggested smokestack is because eveytime I touch selenium I get the same reaction.

You might look into saucelabs. It's free for OSS

from history.

mjackson avatar mjackson commented on April 19, 2024

Well, as of 3dde5ce our testing story is to use zuul to run our tests locally, on sauce labs, and even on Travis. It was really easy to get everything setup, so that's what we'll go with for now.

If someone gets some time/ambition to dig into this further in the future, we can reopen this ticket. But I'm closing for now.

from history.

Related Issues (20)

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.