Reputation: 4026
i have this setup
file1.js:
export function foo1() { ... };
file2.js:
export function foo2() { ... }
hook.js:
import {foo1} from './file1';
import {foo2} from './file2';
export {foo1, foo2};
Now when i want to import from my hook:
app.js
import { foo1 } from '../data/hook.js';
i get this:
Error: invalid argument
When calling foo1. (The function has no arguments/parameters).
Anyone know what's the problem?
UPDATE:
I also get the invalid argument
when importing foo1 directly from file1.
Is this a Babel Problem?
My .babelrcb( i use test as environment):
"env": {
"targets": {
"node": "4.8.4"
},
"test": {
"presets": ["env"]
},
}
UPDATE AND SOLUTION:
It turned out the import was correct, thx for all the guys who helped me on this Q. The problem was due to a Promise inside the function foo1 which caused the import to fail:
browser.waitUntil(..); // see http://webdriver.io/api/utility/waitUntil.html
Upvotes: 0
Views: 259
Reputation: 6364
Function body is missing on file1 and file2.
file1.js:
export function foo1() {};
file2.js:
export function foo2() {};
On hook.js, you should export default.
import {foo1} from './file1';
import {foo2} from './file2';
export default {foo1, foo2};
Upvotes: 1