Storing large arrays for a jasmine test


Let’s suppose I am writing a jasmine test and I want to store large input and output list of doubles (~ 1K values) in order to test that an algorithm is returning the expected result.

Right now I’m simply copying the full list of values in the test setup. Is there a better practice to do that?


@romain.juban Did you ever get a good solution to this?


No. @rileysiebel since you mentioned it in my PR review do you have a solution?


Yes, put the data in a file in the test/seed directory of your package


One solution:

Create a folder structure under test/jasmine such as sample/DoubleArray. Put data files under it such as sample/DoubleArray/myFile.json

myFile.json looks like this:
“values”: [1, 2, 3, 4, …]

Note: DoubleArray is a non-entity type defined in anomalyDetection package but you can define a similar type to hold large arrays.

After provision using -E flag (provision test data) you can access the data in a jasmine test by doing:
var myArray = MetadataStore.tag().file("/base/anomalyDetection/test/jasmine/sample/DoubleArray/myFile.json").readObj().values