GithubHelp home page GithubHelp logo

nfour / fermenter Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 2.0 1.4 MB

A strongly typed Gherkin test runner

JavaScript 0.60% TypeScript 94.98% Gherkin 4.42%
cucumber gherkin jest mocha tests typescript

fermenter's People

Contributors

dependabot[bot] avatar nfour avatar tyas-kusumo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fermenter's Issues

Execute feature file

Execute the feature file against the FeatureBuilder

  • Steps run in correct order
  • Steps reduce state correctly
  • Jest test code output is good-practice and does not execute business logic outside of test() execution

Compatibility with Jest 25

Description

Run test suite using [email protected], this warning is displayed:

Test suite failed to run
      
          Returning a Promise from "describe" is not supported. Tests must be defined synchronously.
          Returning a value from "describe" will fail the test in a future version of Jest.
      
        // file content
      
            at addSpecsToSuite (node_modules/jest-config/node_modules/jest-jasmine2/build/jasmine/Env.js:425:15)
            at describeFeature (packages/feature-suite/node_modules/fermenter/Feature.js:50:13)
            at Feature (packages/feature-suite/node_modules/fermenter/Feature.js:21:5)
            at Object.<anonymous> (packages/feature-suite/specification.feat.js:10:1)

That warning will become a runtime exception in jest@25. Source: https://github.com/facebook/jest/blob/e08be020e9ddcab5b89cd871a2cbd72f006cda7b/packages/jest-jasmine2/src/jasmine/Env.ts#L427

Suggestion

Remove async signature in the callback at

methods.describe(title, async () => {

There's nothing inside that needs await anyway.

Finalize Jest integration

Currently an erroring step definition results in a useless jest error:

(node:23983) UnhandledPromiseRejectionWarning: Error: Couldn't find a match for Step expression:
  I have numbers {int} and {int}
Possible matches:
  I have numbers <num1> and <num2>
  I substract the numbers
  I get <total>

(node:23983) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23983) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

#  FAIL  src/tests/calculator.framework.test.ts

#
#   Your test suite must contain at least one test.
#
#   Stack:
#
#       at node_modules/jest-cli/build/test_scheduler.js:245:22
  • Ensure tests are set-up in a graceful way before Jest executes them
  • Or, surpress the jest error

Abstract away test framework as input

Currently we just use jest globals internally for instrumenting tests.

Instead lets provide them as arguments:

GherkinTest({ feature: './foo.feature', BeforeAll: beforeAll, ... })

Get ScenarioOutlines parsing

ScenarioOutlines can't be parsed because:

(node:16183) UnhandledPromiseRejectionWarning: Error: Couldn't find a match for Step expression:
  I have numbers {int} and {int}
Possible matches:
  I have numbers <num1> and <num2>
  I substract the numbers
  I get <total>

The angle bracket syntax is unknown to the expression parser we are using for regular scenarios.

  • Investigate how CucumberJS does it
    • Use their solution
  • Solve it ourselves

Test file path resolution does not work on windows

.match(/\(([^:]+):/ig)![0]
.replace(/^\(|:$/g, '');

These lines are supposed to grab current path up until the beginning of line number and column number specifier. However, resolved windows path start with drive name and colon. So this code erroneously removes entire path to the file on windows.

Maybe in regex, instead of grabbing until first colon, it is possible to grab everything in parenthesis and then strip last elements?

Composition Root solution

We need to have a concept of a composition root to prime state for a test run.

It does not have to exist in the library or be coupled to any functionality within it.

A GherkinTest cannot expect a blank state for its step definitions as that would impact the complexity of step definitions.

Solution:

  • Have a single file which is responsible for priming state for all tests
  • Step definition functions could declare they are inheriting from the primed state
    • import interfaces for the primed state
    • or, an inject('sdk', 'someVar')() syntax to allow mobx-like composition

More unit tests

We should be doing TDD now that the base of the project is out of heavy prototype stages.

Create tests for:

  • FeatureBuilder
  • GherkinTest
  • lib/ExpressionMatcher
  • lib/matchInGherkinCollection
  • lib/parseGherkinParameters

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.