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

Move some testing helpers into a module #76

Closed
hzoo opened this issue Aug 2, 2016 · 5 comments
Closed

Move some testing helpers into a module #76

hzoo opened this issue Aug 2, 2016 · 5 comments
Labels
Tag: Chore Pull Request updating grunt tasks etc...

Comments

@hzoo
Copy link
Member

hzoo commented Aug 2, 2016

Might be a little less setup?
Something like (maybe need to split up or move arguments around):
Basically always unpad, trim

const babel = require("babel-core");
const unpad = require("utils/unpad");

export function transform(source, plugin, options) {
  return babel.transform(unpad(source),  {
    plugins: [[plugin, options]],
  }).code.trim();
}

export function expectTransform(source, expected, plugin, options = {}) {
  return expect(transform(source, plugin, options)).toBe(unpad(expected));
}
@kangax
Copy link
Member

kangax commented Aug 2, 2016

Good idea.

@kangax kangax added the Tag: Chore Pull Request updating grunt tasks etc... label Aug 10, 2016
@boopathi
Copy link
Member

Also, since we are always checking transformed input to static output, it would make sense to add toMatchSnapshot feature of jest, and we don't have to maintain a separate expected value at all.

I'm not sure if we can use it for any content - though in the docs it says React Component.

@hzoo
Copy link
Member Author

hzoo commented Aug 29, 2016

cc @cpojer?

@cpojer
Copy link
Member

cpojer commented Aug 29, 2016

Jest snapshots work with any serializable value, we just haven't documented it yet. This is actually the ideal use case for snapshots and should allow you guys to move much faster. Also cc @kyldvs who loves using it for strings.

@boopathi
Copy link
Member

Added in #606 . :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tag: Chore Pull Request updating grunt tasks etc...
Projects
None yet
Development

No branches or pull requests

4 participants