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

Best way to read JSON from file for expectJSON parameter? #61

Closed
axschech opened this issue Jan 3, 2014 · 3 comments
Closed

Best way to read JSON from file for expectJSON parameter? #61

axschech opened this issue Jan 3, 2014 · 3 comments

Comments

@axschech
Copy link

axschech commented Jan 3, 2014

Not sure if this is the best place for this but does anyone know the best way to read JSON from a file and use that for the expectJSON parameter? I've done a fair bit of reading and it doesn't seem like there is a way to do it without using a synchronous method.

Perhaps a method could be added to the code base as many testing frameworks feature this option?

@vlucas
Copy link
Owner

vlucas commented Jan 3, 2014

Frisby doesn't yet support this, but I did recently add an expectJSONSchema method that accepts a JSON file or object that represents a JSONSchema.

@axschech
Copy link
Author

axschech commented Jan 3, 2014

Are you using "require(file)" for that? I tried looking through the code but could not really see where you're getting the file from, even though I can see it works!

The problem is that require is not asynchronous, but when I try to use an asyncronous method I don't seem to have anyway of making the Frisby tests wait. Either that, or they don't pick up any tests from within the readFile function.

For example:

fs,readFile(file,etc...)
{

FrisbyTest...

}

The Frisby test never gets picked up. Anyway to get around that?

@vlucas
Copy link
Owner

vlucas commented Jan 3, 2014

I do read the file with a synchronous operation, because the file has to be loaded and read before the test pass/fail can be determined. It's here: https://github.com/vlucas/frisby/blob/master/lib/frisby.js#L705

@vlucas vlucas closed this as completed Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants