Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function specification idea #11

Open
roman01la opened this issue Nov 30, 2016 · 3 comments
Open

Function specification idea #11

roman01la opened this issue Nov 30, 2016 · 3 comments

Comments

@roman01la
Copy link

I can think of an AST transform that could instrument functions. Here's some ideas:

  • Define specs in separate files/modules (with .spec extension, similar to .d.ts in TypeScript)
  • Find a way to map spec modules to JS modules
    • /* @spec path/to/spec.spec */ in JS files?
    • import from "path/to/spec.spec";
  • Match specs with function by name?
  • Use Webpack loader and Babel AST transform to load specs and instrument JS code
@scotttrinh
Copy link

I'd be careful prescribing an extension for this, since a lot of people uses *spec* to match test files, but I'm sure there will be a way to have whatever test-runner or bootstrapping script you use to specify where to find the right files.

@prayerslayer
Copy link
Owner

Wow, that's an interesting suggestion. I don't understand how this would work yet, but worth looking into 👍

@mattbishop
Copy link
Contributor

mattbishop commented Mar 13, 2017

You might want to consider ES Decorators to do this instead of magic places and names. Decorator would create the instrumented code you would need to spec the function params before calling the actual function. See https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841#.khz5wclld

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants