Giter Club home page Giter Club logo

Comments (5)

lneicelis avatar lneicelis commented on May 9, 2024

Interesting thought I like that, may be useful for quite a bit of use cases. However, this syntax is invalid since promise fulfillment callback can receive only one argument, so maybe it should receive result object with report and trace as properties.

from speedracer.

fzaninotto avatar fzaninotto commented on May 9, 2024

Yep, my bad. So it should be:

describe('Prime number finder', () => {
  it('should run under 10s for a 6 digits prime', () => {
    return race('prime race', () => prime(6))
        .then(({ report, trace }) => {
            assert(report.profiling.functions.prime < 10000)
        })
  });
}) 

from speedracer.

ngryman avatar ngryman commented on May 9, 2024

@fzaninotto What you are asking (perf testing) is what's coming next:

Speed Racer will create snapshots of your reports, compare them and tell you what's slower/same/better. Do you think it would fulfil your needs?

To answer your question, for now SR is aimed to be a CLI tool, but 0.4.0 will expose an API so you can customize things the way you want :)

from speedracer.

fzaninotto avatar fzaninotto commented on May 9, 2024

I'm not a fan of snapshot testing. It's like saying: "I don't know precisely why, but it seemed to work in the past". I prefer giving precise conditions (like "it should run under 10s in my example"), that are also meaningful when dumped as error. Besides, snapshot testing forces the developer to commit large data files (the result of previous tests) in the code repository, just for tests... Not my cup of tea.

from speedracer.

ngryman avatar ngryman commented on May 9, 2024

@fzaninotto Well that's a point of vue for general purpose snapshot testing.

In SR context, the way I see it is more like a reference than a source of truth: "it should be around this value" (aka. report.profiling.functions.prime < 10000). Perhaps the term snapshot is misleading...

I think it makes sense in perf testing as a perf test is like a regression test: you want to make sure new features / updates do not alter perf in a bad way. And the way to test it is ... always the same. So instead of having to write imperative code again and again, you take a snapshot as reference and let SR test it for you.

That said, if you want to go further, you could do it in 2 phases:

  • run SR and output reports in a temporary directory.
  • use your favorite test runner to load reports and test them with an assertion library.

0.4.0 will offer an API that let you run races from anywhere, so it will be even simpler and near what you are proposing.

from speedracer.

Related Issues (15)

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.