Skip to content

Commit

Permalink
chore: add selectOption plugin correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwarren1106 committed Oct 6, 2023
1 parent 8596901 commit 612580e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ git remote add upstream git@github.com:modernweb-dev/web.git
Now that you have cloned the repository, ensure you have node 18+ installed, then run the following command to set up the development environment.

```sh
npm run install
npm install
npm run build
```

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions packages/test-runner-commands/browser/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
RemoveFilePayload,
SnapshotPluginConfig,
SaveSnapshotPayload,
SelectOptionPayload,
SendMousePayload,
} from '../dist/index';

Expand Down Expand Up @@ -135,6 +136,23 @@ export function sendKeys(payload: SendKeysPayload): Promise<void>;
**/
export function sendMouse(payload: SendMousePayload): Promise<void>;

/**
* Selects an option in a <select> element by value or label
*
* @example
* ```
* it('natively selects an option by value', async () => {
* const valueToSelect = 'first';
* const select = document.querySelector('#testSelect');
*
* await selectOption({ selector: '#testSelect', value: valueToSelect });
*
* expect(select.value).to.equal(valueToSelect);
*});
*```
*/
export function selectOption(payload: SelectOptionPayload): Promise<void>;

/**
* Resets the mouse position to (0, 0) and releases mouse buttons.
*
Expand Down
2 changes: 2 additions & 0 deletions packages/test-runner-commands/plugins.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cjsEntrypoint from './dist/index.js';
const {
setViewportPlugin,
emulateMediaPlugin,
selectOptionPlugin,
setUserAgentPlugin,
sendKeysPlugin,
sendMousePlugin,
Expand All @@ -15,6 +16,7 @@ const {
export {
setViewportPlugin,
emulateMediaPlugin,
selectOptionPlugin,
setUserAgentPlugin,
sendKeysPlugin,
sendMousePlugin,
Expand Down
1 change: 1 addition & 0 deletions packages/test-runner-commands/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { Viewport, setViewportPlugin } from './setViewportPlugin';
export { Media, emulateMediaPlugin } from './emulateMediaPlugin';
export { selectOptionPlugin, SelectOptionPayload } from './selectOptionPlugin';
export { setUserAgentPlugin } from './setUserAgentPlugin';
export { sendKeysPlugin, SendKeysPayload } from './sendKeysPlugin';
export { sendMousePlugin, SendMousePayload } from './sendMousePlugin';
Expand Down
2 changes: 2 additions & 0 deletions packages/test-runner/src/config/parseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CoverageConfig, TestRunnerCoreConfig, TestRunnerGroupConfig } from '@we
import { chromeLauncher } from '@web/test-runner-chrome';
import {
emulateMediaPlugin,
selectOptionPlugin,
setUserAgentPlugin,
setViewportPlugin,
sendKeysPlugin,
Expand Down Expand Up @@ -251,6 +252,7 @@ export async function parseConfig(
setViewportPlugin(),
emulateMediaPlugin(),
setUserAgentPlugin(),
selectOptionPlugin(),
filePlugin(),
sendKeysPlugin(),
sendMousePlugin(),
Expand Down

0 comments on commit 612580e

Please sign in to comment.