Replies: 3 comments 3 replies
-
const expectedImg = await Jimp.read(
getTestDir(__dirname) + "/images/radius-3-circle.png"
);
const imgSrc = await jimp.read(
mkJGD(
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦"
)
);
expect(imgSrc.circle({ radius: 3 }).bitmap.data).toEqual(
expectedImg.bitmap.data
); example of a unit test |
Beta Was this translation helpful? Give feedback.
1 reply
-
I like the B approach. Using the output images in docs makes a lot of sense too. To make it simpler we could have very simple to understand bmp images and use those for most tests. |
Beta Was this translation helpful? Give feedback.
2 replies
-
I think this is better now. certainly easier to use. And you can us real images now too |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The way tests are constructed is with JGD or so called (Javascript Graphics Description)
It is derived from the design of XPM
Now, my initial reaction is that this is not maintainable, as we have far better tools and IDE support for image viewing in IDE. However, I can also see the advantages of using an XPM like representation in tests
So here are a few suggestions
A. Preserve jgd and only improve error checking and performance (no changes required for tests)
B. Use a "baseline" testing approach. Inputs images are on a directory under tests and the plugin is run against the images then outputs the image. Then, the developer checks the image output and determines if it is the desirable effect. If it is deemed correct, they run a cli command which replaces all baseline images with the new image. If any breaking change is made in the future, the cli will aleart.
Advantages of A
Disadvantages of A
B improves
next
branch might do this)Beta Was this translation helpful? Give feedback.
All reactions