Git Product home page Git Product logo

mocha-cakes-2's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

mocha-cakes-2's Issues

Handle 'context' or 'specify'

small change, but i noticed that mocha cakes 2 doesn't handle context or specify. Which could be useful when we are trying to implement this.

When Each

Is it possible to provide a When step that is executed by multiple scenarios, without duplicating the When call each time.

For example, we have many tests like this:

	var unauthorizedScenarios = 
	[
		{
			description: "No Authorization Header",
			givenDescription: "no authorization header is provided",
			authHeader: null
		},
		{
			description: "Invalid Authorization Header",
			givenDescription: "an authorization header is provided in an incorrect format",
			authHeader: "im-a-key"
		}
	];

		unauthorizedScenarios.forEach(scenario => Scenario(scenario.description, function () {

		Given(scenario.givenDescription, function () {
			authHeader = scenario.authHeader
		});

		When("making an API request that requires authorization", async function () {
			response = await request(config.baseUrl)
				.get("payments/pay_y3oqhf46pyzuxjbcn2giaqnb44")
				.set("Authorization", authHeader);
		});

		Then("it returns HTTP status code 401 (Unauthorized)", function () {
			response.status.should.equal(401);
		});

	}));

What I don't like about this approach is the separation between the scenarios and the tests and it only works in cases where we have the same assertions.

What I would prefer to do is something like:

	WhenEach("Doing something every time", function() {

	});

	ThenEach("Assert on every scenario in the feature", function() {

	});

	Scenario("Scenario 1", function() {
		Given("Some context", function() {

		});

		Then("Scenario specific assertion", function() {

		});
	});

Essentially a WhenEach, GivenEach and ThenEach would run on every scenario. I'm happy to send a PR for this if you can guide me on how best to hook into the scenarios.

Release 3.0.0 on npm

Hi Jens! It seems that the latest version (3.0.0) is not released on npm yet. Would you be kind and publish it? :)

Incompatible with mocha-parallel-tests

mocha-parallel-tests is a package that allows Mocha tests to run in separate processes.
It is a wrapper of Mocha.

However when running tests in parallel that have mocha-cakes-2 in the ui, it doesn't work.
Error:
ReferenceError: feature is not defined

Output customisation, custom reporters

Is there away to customise Mocha-cakes-2 output? i.e. the equivalent of Custom Reporters for mocha.

In some scenarios (i.e. automated runs) we would prefer output to be:

  • less verbose, just a summary of pass/fail counts, maybe a list of failing tests
  • not have special chars such as "โœ“" and the colouring as this can break log parsing.

Issue with app.client.waitUntil inside an async function

Hey there,

I am trying to implement this using spectron and discovered that when calling wdio functions, the whole thing errors out with the error,

at Layer.handle [as handle_request] (../node_modules/express/lib/router/layer.js:95:5)

New hooks breaks normal describe tests.

If you run this with version 3.1.0, it will crash... 3.0.0 worked fine before.

'use strict';

describe('everything', () => {
  it('should work', () => {
    true.should.equal.true;
  });
});

Skip remaining tests when a `Given` or `When` fails

I love the semantics this library adds to my tests.
In particular, I love how this allows me to write "sequential steps", which are clearly dependent on each other. For example:

Given("I have an apple", ...);
When("I eat the apple", ...);
Then("I feel full", ...);
And("I feel healthy", ...);

This gives me very clear "arrange", "act", and "assert" sections (Given, When, Then).

Now imagine that one of my "arrange" or "act" steps fails -- eg. I fail to "eat the apple".
Unfortunately, this results in 3 failed tests.

However, that's not quite what I expect. When an "arrange" or "act" fails, I would expect the "assertions" to be skipped. In other words, if a Given or When fails, all Thens should be skipped. And / But would probably be best categorized based on what preceded them.

Does this make sense? I half-expected this to be the existing behavior, but a quick test reveals that if any Given/When fails, the rest of the assertions are still executed (which often gives confusing results).

Merge with `mocha-cakes`

Hey iensu,

Notice a lot of activity with mocha-cakes-2 as of late!

Was curious if you'd be interested in merging the projects (I am not sure how this would work, but it'll be cool to try). Since mocha-cakes (coffee-script version) haven't been updated in 6 years, thought you'd like to have the npm project name. ๐Ÿ‘

Data driven testing?

Hi,

Is it possible to create data driven tests with this library? I am using this with chakram and would like to avoid creating multiple test cases for same same assertion. Any examples? Thanks,

Reduce blank lines in steps

Awesome job porting this project from CoffeeScript, I really liked it but was having trouble with using CoffeeScript to write my tests. I've modified the code slightly to clean the output a bit by giving the Feature a new line before it and removing the one after, but I'd really like to reduce the lines required for the step to a having no spaces, any idea how I can do this?

  === User model ===

Feature: Unit: #register

    Scenario: failure, ValidationError

          โœ“ Given: a failing email and password combination
          โœ“  When: account registration is attempted
          โœ“  Then: the registration should fail with a ValidationError for a missing em
ail and password

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.