jasonmerino / react-native-simple-store

A minimalistic wrapper around React Native's AsyncStorage.

Home Page:https://www.npmjs.com/package/react-native-simple-store

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RN simple store is breaking my mocha tests

GantMan opened this issue · comments

Whenever I test an object that has RN simple store I get the following:

/Users/gantman/Documents/Projects/rn/trackops-mobile/node_modules/react-native-simple-store/index.js:3
var {
    ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Module._extensions..js (module.js:432:10)

here's a screencap, if that helps at all...

image

I'm using mocha and chai.

Hey! Sorry about the late reply. Which version of Babel are you using?

Babel 6 - Technically "babel": "^6.0.15",

According to this Babel page

Pre-6.x, Babel enabled certain transformations by default. However, Babel 6.x does not ship with any transformations enabled.

Have you

npm install babel-preset-es2015

And added

{
  "presets": ["es2015"]
}

to your .babelrc file?

sorry, I must be missing something. Bringing in es2015 causes a new error.
image

Okay, I've attempted a change on my side. Can you change your package.json to install the babel6 branch from Github directly, rather than NPM. Test that out and see if it works.

The entry for dependencies.react-native-simple-store in your package.json should look like this:

"react-native-simple-store": "git@github.com:jasonmerino/react-native-simple-store.git#babel6"

After making that change run:

npm install

Let me know if that fixes your issue.

I got further, but now I'm stuck at this:
image

Which appears to be a real sticking point: http://stackoverflow.com/questions/32212201/get-mocha-working-with-react-native-errors-w-requiring-addons

It's so funny, my tests run fine until I import the wrong library. I'm really starting to wonder if this testing solution will work. I'm going to attempt to mock these native components, but I'm afraid I won't be able to make this work. I'll let you know, but thanks for the update, it definitely got further.

Interesting. Yeah, mocking these out may work. Good luck. Let me know if you get it working without any more changes on my side.

@GantMan I'm going to close this one out. Please comment to reopen it if there is something I can do to help out with this.

@jasonmerino - your branch does at least fix the babel issue.

I suggest you merge it. I'm still fighting to get other testing features working. But I didn't want this result to go to waste.

ok got past my issues, but 100% depending on your babel branch. Please merge that to master :)

cheers!

@jasonmerino - please add this to master. I'm 100% working on the branch and it's good to go.

@GantMan sorry about not getting back to you earlier. I've learned a little more about how babel interacts with code recently and I'd like to attempt to fix this one a different way. I'll reopen this issue. I'd love your help trying to test this out to get it fixed with babel and the new Ecmascript syntax. I'll probably be able to get to some fixes this week sometime.

happy to help however I can

+1

any updates? I'm still locked to your branch.

@GantMan sorry about the delay here. It's turned into a bit more of a change than I thought. Ends up I'm going to be releasing a transpiled version of the package over NPM which will basically amount to what you're working off in that other branch I set up. Bear with me for a bit and I'll let you know when the new version is out.

@GantMan once again I must apologize for not getting this out earlier... But! I think I have a fix in master for what you were seeing. When you have a moment can you install the version from master and make sure that it doesn't break your tests?

"react-native-simple-store": "git@github.com:jasonmerino/react-native-simple-store.git#master"

@GantMan I'm going to close this out for now. I've published version 1.0.1 which is standard ES5 stuff.

Comment back if you still have trouble after upgrading to the newest version and I'll re-open this and get back to work. :)

Sorry for the delay. Switched from branch to master and everything worked! Cheers!

No worries! Glad to hear it's working. :)