[cli] Tests not detecting errors returned during formatting code
danstepanov opened this issue · comments
Expected Behavior
If any error appears during the process of generating a project, the associated test should fail.
Current Behavior
![Screenshot 2024-01-17 at 3 45 33 PM](https://private-user-images.githubusercontent.com/5482800/297513722-9fc94731-ab70-4b66-8864-c137e64e235e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEzMzUxNTcsIm5iZiI6MTcyMTMzNDg1NywicGF0aCI6Ii81NDgyODAwLzI5NzUxMzcyMi05ZmM5NDczMS1hYjcwLTRiNjYtODg2NC1jMTM3ZTY0ZTIzNWUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MThUMjAzNDE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDE5MTQwMDhhNzk5MjkxN2U5MmU4Y2I0ZmM1NmY1ZmY4NjAyYzc3MDI4M2QwM2I3ZmQ3MzI4ODMyOTY4NTYwZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.jQdL9qAkCu_-aypk3gedO905EBgIbuUHBxLxvu3xUbk)
![Screenshot 2024-01-17 at 3 45 00 PM](https://private-user-images.githubusercontent.com/5482800/297516203-e89f5baf-e547-4d21-8052-43bfdff71ed9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEzMzUxNTcsIm5iZiI6MTcyMTMzNDg1NywicGF0aCI6Ii81NDgyODAwLzI5NzUxNjIwMy1lODlmNWJhZi1lNTQ3LTRkMjEtODA1Mi00M2JmZGZmNzFlZDkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MThUMjAzNDE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Y2IzZmJhYjMwOWY5OWJlNGM2NDZmYTVkM2VhNzAyZDNmNWIxMTdhMTJjYTUyMGM3YmM2NDdiZjVjZjE3OGNiOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.44Yw4ynvSY5jU00-8jTIpZTA1HsO6zBpPn47Uuvqrt4)
Despite the above errors, when running this test individually, the associated test passes.
Possible Solution
GlueGun's system
tool offers spawn()
and run()
commands which both return the result of running a command (either as a string or an object). Perhaps it possible to use the second parameter options
passed to these commands in an effort to log this information or throw [during project generation](url such that the test will fail?
Steps to Reproduce
- Run
npx create-expo-stack@latest myTestProject --expo-router --drawer --nativewind --yarn
- Observe the errors seen in the above screenshot
- Using your local version of create expo stack, run the following test, particularly the one for the above command. Notice that I have added the line
not.toContain('error ')
in an effort to catch that line.
// --expo-router drawer nativewind and yarn
test(`generates a project with expo-router drawer and nativewind with yarn`, async () => {
const output = await cli(`myTestProject --expo-router --drawer --nativewind --yarn`);
console.log('output: ', output)
expect(output).toContain('yarn');
expect(output).not.toContain('error ');
});
- The test will pass, which is incorrect. Upon inspecting the
output
string, you will see that the results of the formatting command run here are not included, despite the fact that they are shown in the cli output to the user.