Failed expectation in test with no expectations
See original GitHub issueI’ve got a test like this:
describe('.traverse/.traverseVisible/.traverseAncestors', () => {
test('they traverse up and down the tree', () => {
a.name = 'parent'
b.name = 'child'
c.name = 'childchild 1'
c.visible = false
d.name = 'childchild 2'
b.add(c)
b.add(d)
a.add(b)
a.traverse(function(obj) {
names.push(obj.name)
})
})
})
It fails on runtime
, rtrace
and configuration-warnings
, but there’s not really any output on rtrace or config branches.
The only somewhat interesting output is on the runtime branch:
❌ src/as/glas/core/Object3D.spec.ts Pass: 1 / 2 Todo: 0 Time: 3.515ms
Object3D.traverse/.traverseVisible/.traverseAncestors
❌ they traverse up and down the tree -
[Expected]: null
[Actual] : null
The odd part is that if you delete the traverse
block, so:
describe('.traverse/.traverseVisible/.traverseAncestors', () => {
test('they traverse up and down the tree', () => {
a.name = 'parent'
b.name = 'child'
c.name = 'childchild 1'
c.visible = false
d.name = 'childchild 2'
b.add(c)
b.add(d)
a.add(b)
})
})
then the test passes.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Failing test with no expectations · Issue #1467 - GitHub
There are some legitimate use cases for tests without assertions, for instance: A test that verifies that an asynchronous process completes.
Read more >Angular testing not invoking expectation resulting to "Spec has ...
Auth Service Testing SPEC HAS NO EXPECTATIONS should return null if there's an error SPEC HAS NO EXPECTATIONS should get users response ...
Read more >Asynchronous Tests and Expectations - Apple Developer
Assert that no errors occurred opening the file asynchronously. XCTAssertNil(error, "Expected no errors loading a file.") // Fulfill the expectation.
Read more >Expectation Declarations - Mockery Docs
In order for our expectations to work we MUST call Mockery::close() , preferably in a callback method such as tearDown or _after (depending...
Read more >Expectations | Pest - An elegant PHP Testing Framework
In addition to assertions, Pest offers you a set of expectations. These functions let you test your values against certain conditions. This API...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You might need to update your local version of
as-pect
as I didn’t change anything in your setup. I just used alog<string>(obj.name)
before and after the push and it only printed the first time, so then I new that it was with how the array was allocated. And from my experience with being burned by empty array literals. The other problems that they had in the past was that since the compiler see it as a literal it lifted it up to the global scope and multiple calls to the a function that declare a literal would still point to that global array. Using the constructor is pretty much always the best way to go.I can tell from your posts that you are attached to the syntax you’ve become accustom to. However, I think it’s a fair compromise if you get type safety and speed. Also there are others in the works. I’m currently working on implementing iterators so that you can use
for (let x of arr)
among other useful features that are currently unavailable. I say this not to stop you from making future issues about lack of features as it is good for new people to find, but just to expect to write less flexible syntax.I tried this out and it seems this is a runtime issue; I got the following error:
When I changed the config to
"--runtime", ["stub"]
, it passed. In this particular case I found that the issue was with initializing the arraynames
with an array literal. Changing the line at the top of the file tomade it pass the test. I’ve been burned by empty array literals in the past and I would avoid them. Perhaps you could make as issue with AS letting them know about this.