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

with_test_harness #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/nightwatch": "^2.3.18",
"@vitejs/plugin-vue": "^4.0.0",
"@vue/test-utils": "^2.2.7",
"chromedriver": "109.0.0",
"chromedriver": "112.0.0",
"eslint-plugin-vue": "9.9.0",
"nightwatch": "2.6.10",
"vite": "^4.0.4"
Expand Down
11 changes: 11 additions & 0 deletions test/component/ToDoForm_TestHarness.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup>
import { ref } from 'vue'
import ToDoForm from "../../src/components/ToDoForm.vue";
const emitted = ref("")

</script>

<template>
<ToDoForm @todo-added="(e) => emitted += e" />
<p id="testHarnessOutput">todo-added: {{ emitted }}</p>
</template>
21 changes: 18 additions & 3 deletions test/component/todoFormTest.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
const delay = ms => new Promise(res => setTimeout(res, ms));

describe('Component test for the TodoForm', function() {

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

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

const labelEl = await component.find('label[for="new-todo-input"]');
expect(labelEl).text.toContain('What needs to be done?');
expect(await component.find('label[for="new-todo-input"]'))
.text.toContain('What needs to be done?');

expect(await component.find('#testHarnessOutput')).text.toBe('todo-added:', );

//await delay(10000);
browser.clearValue('#new-todo-input')
.sendKeys('#new-todo-input', "abc")
.click("button")
.clearValue('#new-todo-input')
.sendKeys('#new-todo-input', "def")
.click("button");

expect(await component.find('#testHarnessOutput')).text.toBe('todo-added: abcdef', );


});

Expand Down