Search code examples
ruby-on-railsteaspoon

Teaspoon: "Can't find variable <function>" (Rails)


So this seems like a weird error, i've just started using teaspoon and im trying to get it set up on a rails project.

I have a very simple function im trying it out on:

export function add(value,value2) {
  return value+value2;
}

Simple right?

and im including it in my spec file as such:

//= require config/add

describe("add", function() {
  var num;
  it("add", function() {
    num = add(2,3);
    expect(num).toEqual(5);
  });
});

Why do I get a "Can't find variable "Add" in http://127.0.0.1:8000/assets/test_spec.self.js?body=1 (line 5)"

Am I missing something? I know this project does have ES6 modules which I know need to be compiled and such, but....this doesn't use any ES6 syntax I believe.


Solution

  • This ended up being a problem with the function export. Which was resolved by using:

    import {add} from 'subfolder/add';
    

    Im guessing since it was using ES6 standards...