zalmoxisus / redux-devtools-test-generator

Generate tests right in Redux DevTools.
https://youtu.be/cbXLohVbzNI?t=392
MIT License
14 stars 1 forks source link

Testing individual reducer instead of root reducer #7

Open lmatteis opened 6 years ago

lmatteis commented 6 years ago

Hi there! Great project.

I was trying to modify the template for a test, thinking it was simply interpreted as an ES6 template literal such as: expect(state).toEqual(${'foo'}); however I get back: expect(state).toEqual(undefined);

Any reason for this? If I had access to the template literal I could run my own expression and test individual reducers instead of just the root reducer:

const slice = ${JSON.stringify(
  JSON.parse(curState).mySlice
)};
expect(state).toEqual(slice);
zalmoxisus commented 5 years ago

Hey! Sorry about missing the question. At the moment this monitor was made, template literals were not supported by browsers and it is done through es6-template. It doesn't eval functions, just get a specific value. I'd like to avoid eval if possible as it makes the extension difficult to pass moderation. For this specific case we could just use the pinned part from Inspector monitor (you could pin a part of the states or actions object and show tests only for it).