0

I've been altering this code for hours and I think it's finally time to ask for help. It's pretty simple, but it doesn't work. I get Customers === undefined

// customers.test.js

import { expect } from 'chai';
import { Customers } from './customers.server.js';

/* eslint-env mocha */

describe('Customers', () => {
  it('customers returns 1', () => {
    expect(Customers).to.eq(1);
  });
});

The above code is working properly, except Customers is undefined. Here's the server controller I'm testing.

 // customers.server.js

 function test1() {
   return 1;
 }

 export default test1();
Tyler L
  • 835
  • 2
  • 16
  • 28
  • Well you aren't exporting a `Customers` class or function. Did you mean to do `import {test1 as Customers} from './customers.server.js';`? – UnholySheep Dec 31 '16 at 18:35
  • 1
    Or rather I guess you meant to write `import Customers from './customers.server.js';` (note that I removed the braces) - See the [MDN doc](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Importing_defaults) for more details – UnholySheep Dec 31 '16 at 18:36
  • The MDN documentation (linked in the above comment) contains everything you need to know. – Felix Kling Dec 31 '16 at 18:42
  • Btw, having the function is useless, you could just do `export default 1;`. – Felix Kling Dec 31 '16 at 18:49

0 Answers0