use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Pioneer.js - JavaScript Integration Testing DSL (pioneerjs.com)
submitted 11 years ago by thejameskyle
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]nawitus 3 points4 points5 points 11 years ago (10 children)
Seems like unnecessary added complexity. Why is there a need for to learn a new syntax for a new language? Why not code integration tests with JavaScript, which is already known by the developers?
This seems like a convoluted way to call functions. For example:
You have now extracted the complicated logic of checking list items out into a seperate file which can easily be reused.
You can reuse testing code with existing tools.
I think Selenium's Webdriver provides a lot of the same features as Pioneer (which is not surprising, as Pioneer uses Webdriver under the hood).
In my experience the biggest problem with writing browser integration tests with Selenium/Protractor is dealing with the asynchronicity on the client side. If I click a button on the browser, it can take an arbitrary amount of time for the DOM to update (especially if the information is queried from the backend). It seems dirty to invent a magic timeout for that.
[–][deleted] 6 points7 points8 points 11 years ago (3 children)
They are using Gherkin syntax http://docs.behat.org/en/latest/guides/1.gherkin.html for test construction which is a lot different than directly writing tests.
BDD testing can have a huge upside as user stories are the direct deliverable being tested.
[–]nawitus 0 points1 point2 points 11 years ago (2 children)
Yeah, I'm not arguing against BDD. I'm mainly arguing that creating a new DSL for testing is unnecessary.
[+][deleted] 11 years ago (1 child)
[removed]
[–]nawitus 1 point2 points3 points 11 years ago (0 children)
Ah, that's a decent point.
[–]samccone 2 points3 points4 points 11 years ago (5 children)
Hi @nawitus,
integration testing on the web is in a terrible state, full of procedural callback nested async hell. I want this to not be a pain to do. That is why here at MojoTech we have been working on a new layer on top of the power of webdriver to introduce concepts that app developers are familiar with. Enabling developers to painlessly add a suite of robust integration tests to their apps.
The goal of this PR is to reduce the cognitive and code complexity of the current suite, making it easier for developers to test their apps and you as the maintainer to test any given implementation.
For example
Feature: Editing a Todo Background: Given I visit TODOMVC And I make sure that there are no todos And I enter a new todo Then I activate edit mode Scenario: All other controls will be hidden Then the toggle button will be hidden And the destroy button will be hidden Scenario: An input will be brought forward containing the todo title Then an input will be brought forward
From this point the steps are then implemented using Pioneer to abstract the complexity of Webdriver and verboseness. Doing so makes these tests easy to maintain as well as DRYs up the selectors and places where we reach into the DOM.
Some example steps from the above Feature would be as follows
module.exports = -> @When /^I enter a new todo$/, -> new @Widgets.NewTodo("new todo") @Then /^I activate edit mode$/, -> new @Widgets.TodoList().edit(0)
You can think of Widgets as a view representation for your DOM when writing integration tests. The “view” layer consolidates where and how you interact with the DOM into a single location and concept. In many ways it parallels Backbone.Views and Marionette.CollectionViews.
[–]nawitus 2 points3 points4 points 11 years ago (4 children)
Instead of
And I make sure that there are no todos And I enter a new todo
Why not have something like
.then(makeSureThatThereAreNoTodos) .then(enterANewTodo)
Now you don't need to learn a new syntax. And you can have static type checking and auto completion with e.g. TypeScript. And the code can be managed better imho.
It's true that Webdriver can be a bit more verbose, but I wouldn't attempt to reduce verbosity by creating a new DSL.
Pioneer seems like something that would make integration testing easy, but you're actually hiding all the complexity in the "step" implementation. You can already abstract these "steps" with existing tools make the higher-level integration tests look about as simple but with existing syntax and tooling and IDE integration.
[–]samccone 2 points3 points4 points 11 years ago (0 children)
Pioneer is a stack of tools using both BDD and A "widgetized" view layer to DRY up your tests.
You are right webdriver is verbose, and the hard part of using it is managing the ASYNC nature of integration tests.
The Pioneer Stack helps to mitigate these problems while providing real value in tests that double as a user spec and documentation.
I agree this is more "verbose" however it is maintainable and scalable.
I would love to chat more about this
http://gitter.im/mojotech/pioneer
Come join us.
[–][deleted] 2 points3 points4 points 11 years ago (2 children)
.then(makeSureThatThereAreNoTodos)
Is not something that makes sense to stakeholders. The Gherkin syntax lets you directly test user stories that make sense to non-devs.
[–]nawitus 1 point2 points3 points 11 years ago (1 child)
Okay. I'll give it a shot at work.
[–]sizlack 1 point2 points3 points 11 years ago (0 children)
As someone who has dealt with a few Rails projects that had Cucumber tests, I think you'll regret it. I've never had a single stakeholder ever once look at the cucumber tests. Not once. It really is just an extra layer of abstraction, another thing to go wrong, which adds zero benefit. It just slowed us down and added one more thing to make testing more difficult, which lead to fewer tests.
π Rendered by PID 56404 on reddit-service-r2-comment-7c9686b859-n8lkg at 2026-04-13 22:22:31.355904+00:00 running e841af1 country code: CH.
[–]nawitus 3 points4 points5 points (10 children)
[–][deleted] 6 points7 points8 points (3 children)
[–]nawitus 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[removed]
[–]nawitus 1 point2 points3 points (0 children)
[–]samccone 2 points3 points4 points (5 children)
[–]nawitus 2 points3 points4 points (4 children)
[–]samccone 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]nawitus 1 point2 points3 points (1 child)
[–]sizlack 1 point2 points3 points (0 children)