Skip to content

CreateObject returns Invalid #128

Description

@xgouchet

I'm trying to test a custom component, using the following code:

  • components/MyComponent.xml:
<component name="MyComponent" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
    <script type="text/brightscript" uri="pkg:/components/MyComponent.brs" />
</component>
  • components/MyComponent.brs:
function init()
    print "init() called"
end function
  • tests/MyComponent.test.brs:
function main(args as object) as object
    return roca(args).describe("A sample test suite", sub()
        m.it("has a task", sub()
            test = CreateObject("roSGNode", "MyComponent")
            m.assert.isValid(test, "Should be valid")
        end sub)
    end sub)
end function

Running the test always fails with the following output:

      m.assert.isValid: Should be valid
      + expected - actual

      -null
      +non-invalid
      
      at m.assert.isValid (src/tests/MyComponent.test.brs:5:12)

Whenever I try creating another type of object, for instance CreateObject("roDeviceInfo"), then the test succeeds.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions