-
-
Notifications
You must be signed in to change notification settings - Fork 372
test: Preact CLI tests #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Refactor, testing build size
Headless chrome, all commands tested
lukeed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chrome stuff looks really cool!
I'm also not sure that there's a need for async-test at all. The test function accepts an opts.timeout value which defaults to 500.
test('possibly long test', { timeout:30000 }, async t => {
// ...
});Feel free to disregard anything 😉 Thanks for taking the time to do all this!
src/commands/create.js
Outdated
| ] : []) | ||
| ].filter(Boolean)); | ||
| } | ||
| spinner.text = 'Installing dependencies'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to move this all under the same if (argv.install). Plus, right now this will display "Installing deps..." when install = false.
tests/build.test.js
Outdated
| 'sw.js': { size: 3905 } | ||
| }; | ||
|
|
||
| const expectedOutputs = prepare({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can totally disregard this, but I typically like to move "expectants" of this size to a separate fixture file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right - just being lazy 😛 I was thinking about some snapshots but the only package i found didn't work
| const listOutput = async dir => await lsr(dir, ['.gitkeep', 'package.json']); | ||
|
|
||
| test('preact create - before', async () => { | ||
| await setup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also prefer to move all the setup()s and clean()s into the test itself, since the presence of async will ensure that those prep/teardowns happen accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I separated them because it the 'main' test fails then they will be called for sure.
It doesn't matter for create or build that much (they could be handled inside tests and in test.onFinish hook), but stuff with chrome get's trickier as we must ensure service worker is unregistered after tests because on non-CI environment service workers could provide false positives (I've tried using profile flag to ensure clean state to no avail).
I thought that consistency between all tests would be easier to maintain & extend.
tests/lib/output.js
Outdated
|
|
||
| export const outputPath = resolve(__dirname, '../output'); | ||
|
|
||
| export const setup = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these can just be:
export const name = () => helper(foo);since they are returning Promises & will be/are awaited in the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what you get for writing in language with native async & await for years. 😅
|
@lukeed I was afraid of
|
|
Where does that |
|
It comes right out of node in console when async test fails using regular tape test. |
|
Oh sorry, I meant a specific test as an example 😃 |
|
Then any test hopefully never 😄 |
CR changes
lukeed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks! 👍 My only suggestion now is to just write a timeout:Number directly into the async-test so that you don't have to define an options object on only some of the tests.
Plus, having the shared timeout won't affect any tests negatively, since the ones that currently don't have a timeout are expected to finish quickly.
Well done!
developit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically perfect, I have no valuable comments to add lol.
| type: 'boolean', | ||
| default: false | ||
| }, | ||
| install: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call.
src/commands/create.js
Outdated
|
|
||
| await fs.writeFile(path.resolve(target, 'package.json'), JSON.stringify(pkg, null, 2)); | ||
|
|
||
| spinner.text = 'Installing dev dependencies'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nitpick (feel free to ignore) - seems like the dev dep message and "done!" message should be inside the if here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I misread the diff last time. Yeah, ^^ what I was trying to say last time. 😴
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I wanted to change it like that! Anyway, should be good now 😆
|
@rkostrzewski @lukeed think we're good to merge? It'd be great to have these running on Travis. To that end, I just enabled travis for the preact-cli repo. I think updating this branch will trigger a build and we can check that everything is peachy there. |
|
@developit hold on I'll work on setting up travis on this branch - I've got a feeling it won't be so easy (I bet timeouts will have to be increased 😝 ) @lukeed I was afraid that on CI dev server tests will run for more than a minute and timeout will get large and could negatively affect hanging tests on PRs (like waiting 15minutes to get result etc). |
This reverts commit 266443b.
This reverts commit 9395884.
|
...many commits later.... It's green! 🎉 😀 I've restarted the build several times to make sure it is reliable. @lukeed assuming you mean sth like @developit I think we're ready to merge! 😀 BTW we can install yarn on travis after yarn PR makes it way and use it to create app - maybe the |
|
That's awesome :D |
# Conflicts: # .gitignore
# Conflicts: # .travis.yml
|
| rkostrzewski dismissed stale reviews from @developit and @lukeed via 7800035 9 days ago |
developit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the one question about sleep
| let { listeners } = await DOMDebugger.getEventListeners({ objectId: object.objectId }); | ||
|
|
||
| if (!listeners.some(l => l.type === 'click')) { | ||
| await pageIsInteractive(chrome, retryCount - 1, retryInterval); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be missing an await sleep(retryInterval)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preact sure is fast as it didn't ever fail on CI AFAIR. 😄 I'll add the delay with smaller interval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done so here.
Is there any trick not to dismiss reviews when committing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, maybe it's a setting..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, just turned that thing off. sorry!
developit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
🙌 🕺 |
Basic tests for every command CLI exposes 🎉
Stuff used:
Stuff changed:
preact createnot to install dependencies