-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
- Loading branch information
1 parent
68d371b
commit 3e83045
Showing
20 changed files
with
277 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["rohit-gohri.format-code-action"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,6 @@ | |
}, | ||
"volta": { | ||
"node": "20.1.0", | ||
"pnpm": "8.5.0" | ||
"pnpm": "8.6.12" | ||
} | ||
} |
158 changes: 158 additions & 0 deletions
158
packages/@glimmer-workspace/integration-tests/lib/suites/error-recovery.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import { tracked } from '../..'; | ||
import { RenderTest } from '../render-test'; | ||
import { test } from '../test-decorator'; | ||
|
||
export class ErrorRecoverySuite extends RenderTest { | ||
static suiteName = 'ErrorRecovery'; | ||
|
||
afterEach() {} | ||
|
||
@test | ||
'by default, errors are rethrown and DOM is cleaned up'() { | ||
const actions = new Actions(); | ||
|
||
class Woops { | ||
get woops() { | ||
actions.record('get woops'); | ||
throw Error('woops'); | ||
} | ||
} | ||
|
||
this.render('message: [{{this.woops.woops}}]', { | ||
woops: new Woops(), | ||
}); | ||
|
||
actions.expect(['get woops']); | ||
this.#assertRenderError('woops'); | ||
|
||
// this.rerender(); | ||
|
||
// actions.expect(['get woops']); | ||
// this.assertRenderError('woops'); | ||
} | ||
|
||
@test | ||
'errors are rethrown during initial render and DOM is cleaned up'() { | ||
const actions = new Actions(); | ||
|
||
class Counter { | ||
@tracked count = 0; | ||
|
||
get message() { | ||
actions.record(`get message`); | ||
if (this.count === 0) { | ||
throw Error('woops'); | ||
} else { | ||
return String(this.count); | ||
} | ||
} | ||
} | ||
|
||
let counter = new Counter(); | ||
|
||
this.render('message: [{{this.counter.message}}]', { | ||
counter, | ||
}); | ||
this.#assertRenderError('woops'); | ||
|
||
actions.expect(['get message']); | ||
|
||
// counter.count++; | ||
|
||
// this.rerender(); | ||
|
||
// this.assertHTML('message: [1]'); | ||
// actions.expect(['get message']); | ||
} | ||
|
||
@test | ||
'errors are rethrown during rerender and DOM is cleaned up'() { | ||
const actions = new Actions(); | ||
|
||
class Counter { | ||
@tracked count = 0; | ||
|
||
get message() { | ||
actions.record(`get message`); | ||
if (this.count === 1) { | ||
throw Error('woops'); | ||
} else { | ||
return String(this.count); | ||
} | ||
} | ||
} | ||
|
||
let counter = new Counter(); | ||
|
||
this.render('message: [{{this.counter.message}}]', { | ||
counter, | ||
}); | ||
|
||
this.assertHTML('message: [0]'); | ||
actions.expect(['get message']); | ||
|
||
// counter.count++; | ||
|
||
// this.rerender(); | ||
|
||
// this.#assertRenderError('woops'); | ||
|
||
// actions.expect(['get message']); | ||
|
||
// counter.count++; | ||
|
||
// this.rerender(); | ||
|
||
// this.assertHTML('message: [2]'); | ||
// actions.expect(['get message']); | ||
} | ||
|
||
// @test | ||
// 'helper destructors run on rollback'(assert: Assert) { | ||
// assert.false(true, 'TODO'); | ||
// } | ||
|
||
// @test | ||
// 'the tracking frame is cleared when an error was thrown'(assert: Assert) { | ||
// assert.false(true, 'TODO'); | ||
// } | ||
|
||
#assertRenderError(message: string) { | ||
if (this.renderResult === null) { | ||
this.assert.ok( | ||
null, | ||
`expecting a RenderResult but didn't have one. Did you call this.render()` | ||
); | ||
return; | ||
} | ||
|
||
if (this.renderResult.error === null) { | ||
this.assert.ok(null, `expecting a render error, but none was found`); | ||
return; | ||
} | ||
|
||
let error = this.renderResult.error.error; | ||
|
||
if (error instanceof Error) { | ||
this.assertHTML('<!---->'); | ||
this.assert.equal(error.message, message); | ||
} else { | ||
this.assert.ok(error, `expecting the render error to be a Error object`); | ||
} | ||
} | ||
} | ||
|
||
class Actions { | ||
#actions: string[] = []; | ||
|
||
record(action: string) { | ||
this.#actions.push(action); | ||
} | ||
|
||
expect(expected: string[]) { | ||
let actual = this.#actions; | ||
this.#actions = []; | ||
|
||
QUnit.assert.deepEqual(actual, expected); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.