Skip to content

Instantly share code, notes, and snippets.

@DanielGallo
Created July 10, 2018 15:23
Show Gist options
  • Save DanielGallo/2f8ae7c311e6edc0cba4e2c44c5759e9 to your computer and use it in GitHub Desktop.
Save DanielGallo/2f8ae7c311e6edc0cba4e2c44c5759e9 to your computer and use it in GitHub Desktop.
Read JSON file in Sencha Test
describe("Read JSON file", function() {
it("should read the data", function(done) {
var fs = require('fs');
var users;
// Go up 2 folder paths in hierarchy
contextPath = contextPath.substring(0, contextPath.lastIndexOf('/'));
fs.readFile(contextPath + '/test.json', 'utf8', function (err, data) {
if (err) {
throw err;
}
users = JSON.parse(data);
expect(users[0].user.name).toBe('Dan');
done();
});
});
});
// This is needed to obtain the current folder path of this test suite. This has to be placed here.
var contextPath = module.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment