Giter Site home page Giter Site logo

bigtestjs / convergence Goto Github PK

View Code? Open in Web Editor NEW
7.0 6.0 1.0 316 KB

All BigTest development has moved to https://github.com/thefrontside/bigtest

Home Page: https://github.com/thefrontside/bigtest

License: MIT License

JavaScript 100.00%
assertions testing testing-tools testing-framework javascript-testing

convergence's People

Contributors

cowboyd avatar minkimcello avatar pittst3r avatar robdel12 avatar wwilsman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

pittst3r

convergence's Issues

Configure ES modules correctly

It is common in a webpack environment when using babel to not transform modules within the node_modules directory. Our package's "module" field points directly to the src files, which are typically compiled with @babel/preset-env. When babel is configured to not compile our packages within node_modules, bundles that use our packages can end up broken.

This can be seen in @bigtest/interaction tests by removing the (!?/@bigtest) regexp within the babel-loader exclude option in the karma.config.js file. This causes the package to fail to properly extend the convergence class and thereby causes every test to fail.

(moved from thefrontside/bigtest#55)

Change "stack" terminology to "queue"

It appears that Convergence#_stack is being used in a FIFO manner, but it's my understanding that a stack is FILO. This conflict is causing me to be confused. Is one of these assumptions incorrect? If not, would "queue" be more accurate?

Mocking Date breaks convergences

Problem

The main convergeOn function uses Date.now to determine if the timeout has been exceeded. When Date is mocked, and specifically when it is mocked to pause time, the convergeOn function hangs forever on failure or when using always.

Potential Solution

Instead of referencing Date globally, we should create a local root reference that can be captured before any mocks are initialized.

Questions about the `Convergence#do` API

In writing type declarations I noticed that the signature of the #do callback is:

type SideEffect<T, U> = (previous: U) => T;

This struck me as odd because I don't like mixing return values and side-effects, and it is my understanding that Convergence#do is primarily about side-effects. In its current incarnation #do does the following:

  • Performs side-effects
  • Maps the previous inner value to a new inner value if provided
  • Flat maps the previous inner value to a new inner value if provided a Convergence or Promise instance

Basically, I guess I am wondering if it would make sense to restrict #do to side-effects only and create two new methods: #map and #flatMap, which take care of the other two bullet points respectively.

The signatures would go from this:

declare class Convergence<T> {
  // ...
  do<U>(callback: (previous: T) => U): Convergence<U>;
}

To this:

declare class Convergence<T> {
  // ...
  do(callback: (previous: T) => void): Convergence<T>;
  map<U>(callback: (previous: T) => U): Convergence<U>;
  flatMap<U>(callback: (previous: T) => Convergence<U> | Promise<U>): Convergence<U>;
}

Of note is the fact that this change would make it possible to have higher-order convergences (increasing the API surface area a bit), the implications of which I have not thought through yet and I don't know if that would be good or bad.

Just wanted to kick off this discussion and see if what I'm thinking makes sense or if I'm off base.

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.