1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-09-09 21:50:59 +02:00

combine unit and e2e coverage, simplify test scripts

This commit is contained in:
Morris Brodersen
2024-01-29 23:52:14 +01:00
parent 9991ec23b1
commit dd29d07d31
6 changed files with 81 additions and 38 deletions

View File

@@ -5,7 +5,7 @@ import { test } from 'playwright/test';
// See also https://playwright.dev/docs/api/class-coverage
if (process.env.COVERAGE) {
if (process.env.NODE_V8_COVERAGE) {
test.beforeEach(async ({ page }) => {
await page.coverage.startJSCoverage();
});
@@ -20,9 +20,9 @@ if (process.env.COVERAGE) {
})),
};
await fs.mkdir('coverage/tmp', { recursive: true });
await fs.mkdir(process.env.NODE_V8_COVERAGE, { recursive: true });
await fs.writeFile(
`coverage/tmp/coverage-${randomUUID()}.json`,
path.join(process.env.NODE_V8_COVERAGE, `coverage-${randomUUID()}.json`),
JSON.stringify(output),
);
});

View File

@@ -139,3 +139,46 @@ test('TodoLogic.moveTodoItem', () => {
},
]);
});
test('TodoLogic.checkTodoItem', () => {
let data = TodoLogic.initTodoData(new Date(0));
data = {
...data,
items: [
{
id: 'a',
listId: '1970-01-01',
label: 'foo',
index: 0,
done: false,
},
{
id: 'b',
listId: '1970-01-01',
label: 'bar',
index: 1,
done: false,
},
],
};
data = TodoLogic.checkTodoItem(data, { id: 'a', done: true });
expect(data.items).toEqual([
{
id: 'a',
listId: '1970-01-01',
label: 'foo',
index: 0,
done: true,
},
{
id: 'b',
listId: '1970-01-01',
label: 'bar',
index: 1,
done: false,
},
]);
});