Skip to content
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

Wrap @web/test-runner binary #65

Merged
merged 30 commits into from
Jul 21, 2023
Merged

Wrap @web/test-runner binary #65

merged 30 commits into from
Jul 21, 2023

Conversation

bearfriend
Copy link
Contributor

@bearfriend bearfriend commented Jul 11, 2023

US154135: Visual-diff: wrap web-test-runner binary

Use is largely the same. Notable changes:

  • Commands: wtr/web-test-runner -> d2l-test
  • Browser names: chromium -> chrome, webkit -> safari
  • Config file:
    • web-test-runner.config.js -> d2l-test.config.js
    • Now just a simple POJO export. No more createConfig or getBrowsers
  • Options:
    • --files is now an explicit option
    • --group is now the implicit option, with unit being the default (i.e. d2l-test and d2l-test unit run the unit group)
    • --filter no longer adds leading and trailing wildcards. So, in core d2l-test -f list will only find list.test.js. Add your own wildcards to match more: -f list* or -f *list*

Most wtr options will pass through, but some are explicitly disabled to avoid overwriting the d2l-test config.

bin/test.js Outdated Show resolved Hide resolved
const requestedBrowsers = ALLOWED_BROWSERS.filter(b => cliArgs?.[b]);
this.#requestedBrowsers = requestedBrowsers.length && requestedBrowsers;
}

get #defaultConfig() {
return {
files: this.#getPattern('test'),
Copy link
Contributor Author

@bearfriend bearfriend Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this disables the default group

bin/test.js Outdated
@@ -126,44 +138,34 @@ export class WTRConfig {
}

#getPattern(type) {
const pattern = this.#cliArgs.files || this.pattern(type);
const pattern = [].concat(this.#cliArgs.files || this.pattern(type));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows --files option (which will be an array) to be filtered properly

bin/test.js Outdated
return `+(${fileGlobs.join('|')})`;
});
});
return `+(${fileGlobs.join('|') || fileGlob})`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handles bad POSIX CLI globs gracefully.

--files ./*.test.js is converted by the OS to a list of all matching files (with no * characters) before being sent to the process.
--files './*.test.js' is what should be used. We can add standard POSIX glob note to docs.

bin/test.js Outdated
Comment on lines 160 to 166
if (!group || group === 'default') {
if (playwright) {
console.warn('Warning: reducedMotion disabled. Use the unit group to enable reducedMotion.');
} else {
console.warn('Warning: Running with puppeteer, reducedMotion disabled. Use the unit group to use playwright with reducedMotion enabled');
}
}
Copy link
Contributor Author

@bearfriend bearfriend Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer necessary since we are disabling default group and defaulting to unit group (and forcing all browsers options to playwright browsers).

bin/test.js Outdated
});

if (vdiff) {
if (group === 'vdiff') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more vdiff: true. Just use the group to enable it.

src/server/index.js Outdated Show resolved Hide resolved
@@ -112,7 +112,7 @@ export function visualDiffReporter({ reportResults = true } = {}) {
cpSync(inputDir, tempDir, { force: true, recursive: true });
writeFileSync(join(tempDir, 'data.js'), `export default ${json};`);

execSync(`rollup -c ${join(__dirname, './rollup.config.js')}`);
execSync(`npx rollup -c ${join(__dirname, './rollup.config.js')}`, { stdio: 'pipe' });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npx fixes command not found error, which I believe is necessary now the way this runs.

stdio fixes the double output, though I'm not sure why, since it's supposed to be the default. May need to make this ignore if it spits out other bad things.

@bearfriend bearfriend marked this pull request as ready for review July 12, 2023 12:53
@bearfriend bearfriend requested a review from a team as a code owner July 12, 2023 12:53
@bearfriend
Copy link
Contributor Author

Tests in progress

bin/test.js Outdated Show resolved Hide resolved
bin/test.js Outdated Show resolved Hide resolved
src/server/visual-diff-reporter.js Show resolved Hide resolved
bin/test.js Outdated Show resolved Hide resolved
bin/test.js Outdated Show resolved Hide resolved
test/browser/d2l-test.config.js Outdated Show resolved Hide resolved
bin/test.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved

it('should not forward disallowed or stolen options', async() => {
const disallowed = ['--browsers', '--playwright', '--puppeteer', '--groups'];
const stolen = ['--config'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 stolen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah. I tried to avoid it at first but then when I got to borrowed it seemed like the most accurate word.

src/server/cli/test.js Outdated Show resolved Hide resolved
order: 1
},
{
name: 'manual',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I raised this here or the other PR, this will still be removed in a future PR?


// d2l-test options
{
name: 'chrome',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I was thinking about - does this affect the browser names the runner has? Will the goldens be stored in chrome and safari folders, or still chromium and webkit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing else changes. I did start second-guessing this because literally everything else will not match these. Directories, test output, report tabs, (playwright/wtr options).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's convenient but makes me like it a bit less if everything else will still say the old name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to switch what the report shows if that's what we're worried about. The output in the console though will still say "chromium" and "webkit". Surprised Firefox doesn't resort to "gecko".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the weirdest part for me would be the folders not matching, which I guess we could change by having a map in the plugin.

src/server/wtr-config.js Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@bearfriend bearfriend merged commit 385dc31 into main Jul 21, 2023
1 check passed
@bearfriend bearfriend deleted the dgleckler/bin-wrap branch July 21, 2023 13:38
@ghost
Copy link

ghost commented Jul 21, 2023

🎉 This PR is included in version 0.18.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ghost ghost added the released label Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants