Skip to content

Commit 850b8c4

Browse files
committed
build: upgrade deps to latest
- Verbose report for unit tests - Add more validator unit tests - Add reportSlowTests config to Playwright
1 parent fc499b2 commit 850b8c4

File tree

5 files changed

+78
-29
lines changed

5 files changed

+78
-29
lines changed

package-lock.json

+24-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"pre-commit": "node ./scripts/pre-commit.js",
2525
"prebuild": "npm run version",
2626
"preview": "svelte-kit preview",
27+
"test": "npm run test:unit",
2728
"test:e2e": "playwright test",
2829
"test:e2e:codegen": "playwright codegen http://localhost:3000",
2930
"test:e2e:debug": "PWDEBUG=1 playwright test",
@@ -35,7 +36,7 @@
3536
"@nasa-jpl/stellar": "^1.0.3",
3637
"@playwright/test": "^1.22.2",
3738
"@sveltejs/adapter-node": "1.0.0-next.78",
38-
"@sveltejs/kit": "1.0.0-next.350",
39+
"@sveltejs/kit": "1.0.0-next.354",
3940
"@testing-library/svelte": "^3.1.3",
4041
"@types/cookie": "^0.5.1",
4142
"@types/d3-axis": "^3.0.1",
@@ -82,7 +83,7 @@
8283
"tslib": "^2.4.0",
8384
"typescript": "^4.7.4",
8485
"unique-names-generator": "^4.7.1",
85-
"vitest": "^0.15.2",
86+
"vitest": "^0.16.0",
8687
"vitest-svelte-kit": "^0.0.6"
8788
}
8889
}

playwright.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import type { PlaywrightTestConfig } from '@playwright/test';
22

33
const config: PlaywrightTestConfig = {
44
forbidOnly: !!process.env.CI,
5+
reportSlowTests: {
6+
max: 0,
7+
threshold: 60000,
8+
},
59
reporter: [
610
[process.env.CI ? 'github' : 'list'],
711
['html', { open: 'never', outputFile: 'index.html', outputFolder: 'e2e-test-results' }],

src/utilities/validators.test.ts

+46-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect, test } from 'vitest';
2-
import { min } from './validators';
2+
import { min, required, timestamp } from './validators';
33

4-
describe('min', async () => {
4+
describe('min', () => {
55
const value = 5;
66
const error = `Field cannot be less than ${value}`;
77

@@ -17,3 +17,47 @@ describe('min', async () => {
1717
expect(invalidMsg).toEqual(null);
1818
});
1919
});
20+
21+
describe('required', () => {
22+
const error = 'Field is required';
23+
24+
test('Should return an error message if input is NaN', async () => {
25+
const invalidMsg = await required(NaN);
26+
expect(invalidMsg).toEqual(error);
27+
});
28+
29+
test('Should return an error message if input is the empty string', async () => {
30+
const invalidMsg = await required('');
31+
expect(invalidMsg).toEqual(error);
32+
});
33+
34+
test('Should return null if input is a non-empty string', async () => {
35+
const invalidMsg = await required('hello');
36+
expect(invalidMsg).toEqual(null);
37+
});
38+
39+
test('Should return null if input is a number', async () => {
40+
const invalidMsg = await required(42);
41+
expect(invalidMsg).toEqual(null);
42+
});
43+
});
44+
45+
describe('timestamp', () => {
46+
const doyError = 'DOY format required: YYYY-DDDThh:mm:ss';
47+
const rangeError = 'Day-of-year must be between 0 and 365';
48+
49+
test('Should return an error message if input not in DOY format', async () => {
50+
const invalidMsg = await timestamp('2020-001');
51+
expect(invalidMsg).toEqual(doyError);
52+
});
53+
54+
test('Should return an error message if input is out of DOY range', async () => {
55+
const invalidMsg = await timestamp('2020-400T00:00:00.000');
56+
expect(invalidMsg).toEqual(rangeError);
57+
});
58+
59+
test('Should return null if input is input is a valid DOY string', async () => {
60+
const invalidMsg = await timestamp('2020-001T00:00:00.000');
61+
expect(invalidMsg).toEqual(null);
62+
});
63+
});

svelte.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const config = {
1010
environment: 'jsdom',
1111
include: ['./src/**/*.test.ts'],
1212
outputFile: 'unit-test-results/json-results.json',
13-
reporters: ['default', 'json'],
13+
reporters: ['verbose', 'json'],
1414
},
1515
},
1616
},

0 commit comments

Comments
 (0)