In dps909 this week we were asked to help a group project to convert all the processing.js examples in the seneca directory into ref tests. The examples are sketches that were created in the early stages of processing.js. Most sketches have an image of how the sketch looks in p5 and then it renders it using pjs. After the sketches have been loaded, it is up to the user to compare the sketches. As pjs grows, these tests have multiplied to the point where all the tests cannot be performed manually. Ref tests takes a series of pixel information from a passed test so it can be used to check the same sketch in the future. With this pixel information, tests can be performed and checked easily and quickly.
Its very simple to create ref tests. Go to the seneca directory of pjs and run an example. Take the sketch code and run it in p5. Compare it to the result in p5.
Sketch Code:
void setup() {
size();
background(153);
}
void draw() {
line(0, 0, width, height);
}
p5 | pjs |
---|---|
![]() |
![]() |
Being that the sketches look the same, we can create a ref test using the pjs helper. The result is a ref test that can be saved as a pde file and placed in the ref test directory. Information on the tests I completed can be found on my wiki.
