Including a app-defined object in test


#1

I am creating an integration test, and my component accepts a application-defined object, of which the class definition is stored in a file called my-object.js.

Perhaps I am completely missing it, but I cannot seem to write an import statement at the top of my integration test that allows me to create instances of my-object.

I’ve tried relative paths:

import MyObject from '../../../../app/custom-objects/my-object';

one, defined from app… I’ve tried relative paths:

import MyObject from 'custom-objects/my-object';

Can someone point me in the right direction?


#2

What are the actual paths on disk (relative to the project root) for:

  • the object you are attempting to import
  • the test file that you are importing from

#3

anh [21:31]

@rwjblue:

  • {{root}}/app/pods/components/multitab-form/tab-item.js
  • {{root}}/tests/integration/pods/components/multitab-form/component-test.js (edited)

rwjblue [21:34]

Either:

import TabItem from '<app-name>pods/components/multitab-form/tab-item';

Or

import TabItem from '../../../../../pods/components/multitab-form/tab-item';

​[21:34] (I think)

​[21:34] Even though tests/ is in the same dir as app/ when it is transpiled, it is moved “under” the app namespace (aka app/)

​[21:34] it makes the relative imports very weird

​[21:35] @anh: lemme know if those don’t work

anh [21:37] thanks @rwjblue : the first one works!