question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed expectation in test with no expectations

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
willemnealcommented, Jun 13, 2019

You might need to update your local version of as-pect as I didn’t change anything in your setup. I just used a log<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.

1reaction
willemnealcommented, Jun 13, 2019

I tried this out and it seems this is a runtime issue; I got the following error:

[Describe]: Object3D.traverse/.traverseVisible/.traverseAncestors

    [Fail]: ✖ they traverse up and down the tree

   [Actual]: null
               at node_modules/as-pect/assembly/internal/report/reportActual/__sendActual (wasm-function[106]:115)

 [Expected]: null
               at node_modules/as-pect/assembly/internal/report/reportExpected/__sendExpected (wasm-function[107]:150)

    [Stack]: Error: not a string: 0
               at ~lib/rt/tlsf/insertBlock (wasm-function[25]:342)
               at ~lib/rt/tlsf/reallocateBlock (wasm-function[79]:231)
               at ~lib/rt/tlsf/__realloc (wasm-function[80]:61)
               at ~lib/array/ensureSize (wasm-function[82]:66)
               at ~lib/array/Array<~lib/string/String>#push (wasm-function[97]:28)
               at start:src/as/glas/core/Object3D.spec~anonymous|0~anonymous|1~anonymous|0~anonymous|0 (wasm-function[98]:13)
               at src/as/glas/core/Object3D/Object3D#traverse (wasm-function[99]:11)

  [Result]: ✖ FAIL
   [Tests]: 0 pass, 1 fail, 1 total
    [Todo]: 0 tests
    [Time]: 2.4ms

When I changed the config to "--runtime", ["stub"], it passed. In this particular case I found that the issue was with initializing the array names with an array literal. Changing the line at the top of the file to

const names: string[] = new Array<string>()

made 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found