Skip to content

Commit dd2e95b

Browse files
committed
with_test_harness
1 parent ab9121e commit dd2e95b

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@types/nightwatch": "^2.3.18",
2323
"@vitejs/plugin-vue": "^4.0.0",
2424
"@vue/test-utils": "^2.2.7",
25-
"chromedriver": "109.0.0",
25+
"chromedriver": "112.0.0",
2626
"eslint-plugin-vue": "9.9.0",
2727
"nightwatch": "2.6.10",
2828
"vite": "^4.0.4"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script setup>
2+
import { ref } from 'vue'
3+
import ToDoForm from "../../src/components/ToDoForm.vue";
4+
const emitted = ref("")
5+
6+
</script>
7+
8+
<template>
9+
<ToDoForm @todo-added="(e) => emitted += e" />
10+
<p id="testHarnessOutput">todo-added: {{ emitted }}</p>
11+
</template>

test/component/todoFormTest.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1+
const delay = ms => new Promise(res => setTimeout(res, ms));
2+
13
describe('Component test for the TodoForm', function() {
24

35
browser.baseUrl = browser.baseUrl || 'http://localhost:3000';
46

57
it('render and test the component', async function(browser) {
6-
const component = await browser.mountComponent('/src/components/ToDoForm.vue');
8+
const component = await browser.mountComponent('/test/component/ToDoForm_TestHarness.vue');
79
browser.expect(component).to.be.visible;
810

9-
const labelEl = await component.find('label[for="new-todo-input"]');
10-
expect(labelEl).text.toContain('What needs to be done?');
11+
expect(await component.find('label[for="new-todo-input"]'))
12+
.text.toContain('What needs to be done?');
13+
14+
expect(await component.find('#testHarnessOutput')).text.toBe('todo-added:', );
15+
16+
//await delay(10000);
17+
browser.clearValue('#new-todo-input')
18+
.sendKeys('#new-todo-input', "abc")
19+
.click("button")
20+
.clearValue('#new-todo-input')
21+
.sendKeys('#new-todo-input', "def")
22+
.click("button");
23+
24+
expect(await component.find('#testHarnessOutput')).text.toBe('todo-added: abcdef', );
25+
1126

1227
});
1328

0 commit comments

Comments
 (0)