Closed herschelrs closed 1 year ago
Hello @herschelrs,
I saw this in Discord:
If you are the guy who wrote this, the problem here is that there were no errors when you built the project. The thing you referred to is a warning that can be safely ignored.
Just reinstall the dependencies and try running the tests without npm audit --fix
.
This question is separate from the one I posted on discord. When I run your actual test suite I get only like 94% passing.
I reran the tests, and they all pass. Please provide some details of your setup: which tests fail (some logs would be helpful), which Node version you use, etc.
Here you are:
herschel@X1C:~/obsidian-task-archiver$ npm run test
> obsidian-task-archiver@0.12.0 test
> jest --collectCoverage
PASS src/parser/__tests__/SectionParser.test.js
PASS src/features/__tests__/ListToHeadingTransformer.test.js
PASS src/features/__tests__/TaskListSorter.test.js
FAIL src/features/__tests__/Archiver.test.js
● Date tree › Archives tasks under a bullet with the current week
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
Array [
"- [ ] bar",
"# Archived",
"",
- "- [[2021-01-W-1]]",
+ "- [[2020-12-W-1]]",
" - [x] foo",
"",
]
33 | ) {
34 | const [testDependencies] = await archiveTasks(activeFileState, settings);
> 35 | expect(testDependencies.mockActiveFile.state).toEqual(expectedActiveFileState);
| ^
36 | }
37 |
38 | async function archiveTasks(activeFileState, settings) {
at archiveTasksAndCheckActiveFile (src/features/__tests__/Archiver.test.js:35:51)
at Object.<anonymous> (src/features/__tests__/Archiver.test.js:335:9)
● Date tree › Uses indentation values from settings
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
Array [
"# Archived",
"",
- "- [[2021-01-W-1]]",
+ "- [[2020-12-W-1]]",
" - [x] foo",
"",
]
33 | ) {
34 | const [testDependencies] = await archiveTasks(activeFileState, settings);
> 35 | expect(testDependencies.mockActiveFile.state).toEqual(expectedActiveFileState);
| ^
36 | }
37 |
38 | async function archiveTasks(activeFileState, settings) {
at archiveTasksAndCheckActiveFile (src/features/__tests__/Archiver.test.js:35:51)
at Object.<anonymous> (src/features/__tests__/Archiver.test.js:346:9)
● Date tree › Appends tasks under the current week bullet if it exists
expect(received).toEqual(expected) // deep equality
- Expected - 0
+ Received + 1
@@ -3,8 +3,9 @@
"",
"- [[old week]]",
" - [x] old task",
"- [[2021-01-W-1]]",
" - [x] baz",
+ "- [[2020-12-W-1]]",
" - [x] foo",
"",
]
33 | ) {
34 | const [testDependencies] = await archiveTasks(activeFileState, settings);
> 35 | expect(testDependencies.mockActiveFile.state).toEqual(expectedActiveFileState);
| ^
36 | }
37 |
38 | async function archiveTasks(activeFileState, settings) {
at archiveTasksAndCheckActiveFile (src/features/__tests__/Archiver.test.js:35:51)
at Object.<anonymous> (src/features/__tests__/Archiver.test.js:361:9)
● Date tree › Days › Archives tasks under a bullet with the current day
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
Array [
"- [ ] bar",
"# Archived",
"",
- "- [[2021-01-01]]",
+ "- [[2020-12-31]]",
" - [x] foo",
"",
]
33 | ) {
34 | const [testDependencies] = await archiveTasks(activeFileState, settings);
> 35 | expect(testDependencies.mockActiveFile.state).toEqual(expectedActiveFileState);
| ^
36 | }
37 |
38 | async function archiveTasks(activeFileState, settings) {
at archiveTasksAndCheckActiveFile (src/features/__tests__/Archiver.test.js:35:51)
at Object.<anonymous> (src/features/__tests__/Archiver.test.js:389:13)
● Date tree › Combining dates › Creates & indents weekly & daily blocks
expect(received).toEqual(expected) // deep equality
- Expected - 2
+ Received + 2
Array [
"- [ ] bar",
"# Archived",
"",
- "- [[2021-01-W-1]]",
- " - [[2021-01-01]]",
+ "- [[2020-12-W-1]]",
+ " - [[2020-12-31]]",
" - [x] foo",
"",
]
33 | ) {
34 | const [testDependencies] = await archiveTasks(activeFileState, settings);
> 35 | expect(testDependencies.mockActiveFile.state).toEqual(expectedActiveFileState);
| ^
36 | }
37 |
38 | async function archiveTasks(activeFileState, settings) {
at archiveTasksAndCheckActiveFile (src/features/__tests__/Archiver.test.js:35:51)
at Object.<anonymous> (src/features/__tests__/Archiver.test.js:402:13)
● Date tree › Combining dates › The week is already in the tree
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 2
Array [
"- [ ] bar",
"# Archived",
"",
"- [[2021-01-W-1]]",
- " - [[2021-01-01]]",
+ "- [[2020-12-W-1]]",
+ " - [[2020-12-31]]",
" - [x] foo",
"",
]
33 | ) {
34 | const [testDependencies] = await archiveTasks(activeFileState, settings);
> 35 | expect(testDependencies.mockActiveFile.state).toEqual(expectedActiveFileState);
| ^
36 | }
37 |
38 | async function archiveTasks(activeFileState, settings) {
at archiveTasksAndCheckActiveFile (src/features/__tests__/Archiver.test.js:35:51)
at Object.<anonymous> (src/features/__tests__/Archiver.test.js:422:13)
● Date tree › Combining dates › The week and the day are already in the tree
expect(received).toEqual(expected) // deep equality
- Expected - 0
+ Received + 2
@@ -2,8 +2,10 @@
"- [ ] bar",
"# Archived",
"",
"- [[2021-01-W-1]]",
" - [[2021-01-01]]",
+ "- [[2020-12-W-1]]",
+ " - [[2020-12-31]]",
" - [x] foo",
"",
]
33 | ) {
34 | const [testDependencies] = await archiveTasks(activeFileState, settings);
> 35 | expect(testDependencies.mockActiveFile.state).toEqual(expectedActiveFileState);
| ^
36 | }
37 |
38 | async function archiveTasks(activeFileState, settings) {
at archiveTasksAndCheckActiveFile (src/features/__tests__/Archiver.test.js:35:51)
at Object.<anonymous> (src/features/__tests__/Archiver.test.js:442:13)
● Date tree › Combining dates › The day is there, but the week is not (the user has changed the configuration)
expect(received).toEqual(expected) // deep equality
- Expected - 2
+ Received + 2
Array [
"- [ ] bar",
"# Archived",
"",
"- [[2021-01-01]]",
- "- [[2021-01-W-1]]",
- " - [[2021-01-01]]",
+ "- [[2020-12-W-1]]",
+ " - [[2020-12-31]]",
" - [x] foo",
"",
]
33 | ) {
34 | const [testDependencies] = await archiveTasks(activeFileState, settings);
> 35 | expect(testDependencies.mockActiveFile.state).toEqual(expectedActiveFileState);
| ^
36 | }
37 |
38 | async function archiveTasks(activeFileState, settings) {
at archiveTasksAndCheckActiveFile (src/features/__tests__/Archiver.test.js:35:51)
at Object.<anonymous> (src/features/__tests__/Archiver.test.js:469:13)
------------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------------------------|---------|----------|---------|---------|-------------------
All files | 97.55 | 89.38 | 100 | 97.53 |
src | 94.69 | 83.33 | 100 | 94.69 |
ActiveFile.ts | 83.33 | 75 | 100 | 83.33 | 23
Patterns.ts | 100 | 100 | 100 | 100 |
Util.ts | 94.73 | 84.21 | 100 | 94.73 | 28,55,108,151,157
src/features | 98.08 | 90 | 100 | 98.07 |
Archiver.ts | 98.59 | 85.71 | 100 | 98.59 | 224
DateTreeResolver.ts | 96.29 | 87.5 | 100 | 96.15 | 53
ListToHeadingTransformer.ts | 100 | 100 | 100 | 100 |
TaskListSorter.ts | 100 | 100 | 100 | 100 |
TaskTester.ts | 91.66 | 90 | 100 | 91.66 | 48
src/features/__tests__ | 100 | 100 | 100 | 100 |
Util.js | 100 | 100 | 100 | 100 |
src/model | 100 | 100 | 100 | 100 |
Block.ts | 100 | 100 | 100 | 100 |
ListBlock.ts | 100 | 100 | 100 | 100 |
MarkdownNode.ts | 100 | 100 | 100 | 100 |
RootBlock.ts | 100 | 100 | 100 | 100 |
Section.ts | 100 | 100 | 100 | 100 |
TextBlock.ts | 0 | 0 | 0 | 0 |
src/parser | 100 | 100 | 100 | 100 |
BlockParser.ts | 100 | 100 | 100 | 100 |
SectionParser.ts | 100 | 100 | 100 | 100 |
TreeBuilder.ts | 100 | 100 | 100 | 100 |
------------------------------|---------|----------|---------|---------|-------------------
Test Suites: 1 failed, 3 passed, 4 total
Tests: 8 failed, 74 passed, 82 total
Snapshots: 0 total
Time: 4.842 s
Ran all test suites.
herschel@X1C:~/obsidian-task-archiver$ npm -v
8.19.2
herschel@X1C:~/obsidian-task-archiver$ node -v
v12.22.9
herschel@X1C:~/obsidian-task-archiver$ node -v
That's the same error in every test. Looks like your system interprets new Date("2021-01-01").getTime()
as the time in 2020-12-31 instead of 2021-01-01. I couldn't reproduce it even on your Node version, but I shifted the time in tests a bit. Try re-running them on the latest master.
Sorry for taking so long. That fixed the tests. I don't understand the error terribly well but I'm sort of assuming that there's some problematic assumption wrt the Date
constructor which you didn't necessarily resolve? Anyway, I'll close this.
Yes, I don't consider this important enough to investigate.
I started looking around, thinking about extending your plugin, but I noticed that you're getting some failing tests, at least on
fade877
on master. Not sure if this is expected/if it's reasonable to start writing something anyway.