question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move some testing helpers into a module

See original GitHub issue

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));
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
cpojercommented, 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.

0reactions
boopathicommented, Aug 13, 2017

Added in #606 . 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rails: Moving a helper method form a test to test_helper.rb
Turns out that I had to wrap the helper method into a module: # test_helper.rb class ActionController::TestCase module CheatWithAuth do def ...
Read more >
Move useful helper methods for working with entities ... - Drupal
Move useful helper methods for working with entities to the KernelTestBase class. Other possibilities were: a. Remove the 'entity_test' module ...
Read more >
Modules And Helpers - Codeception Docs
All actions and assertions that can be performed by the Tester object in a class are defined in modules. You can extend the...
Read more >
Test helpers | Spryker Documentation
These helpers allow you to hook into the lifecycle of tests and get handy methods available wherever the helper is enabled. Codeception and ......
Read more >
No way to use helpers/modules inside dataprovider methods
I have some helpers to create common Stubs. These work fine in the test methods. However, as above, these cannot be used in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found