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
you have to add ./
in import and default
in the export
export default function foo1()
import {foo1} from './File1'
otherwise, it will search for File1 in node_modules
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};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.