Testing with Mocha, when I add import my test goes away


#1

Hi, I have a question about Mocha. I’m using Meteor/React and trying to write a basic test that checks if it renders. I’m following along with this article here.

Here is what my test looks like

client/prospects/ProspectForm.tests.js

import { Meteor } from 'meteor/meteor'
import { Factory } from 'meteor/dburles:factory'
import ProspectForm from './ProspectForm.jsx'
import React from 'react';
import { shallow } from 'enzyme'
import { chai } from 'meteor/practicalmeteor:chai'

describe('ProspectForm', () => {
  it('should render', () => {
  const prospectForm = shallow(<ProspectForm />)

  chai.assert(prospectForm.hasClass('field'))
  })
})

Everything worked until I added

import { shallow } from 'enzyme'

When I did that, my test went away from the browser, and it looks like this.

My first question is why would putting that line make my test disappear from the browser list of tests? If something is wrong, why doesn’t it just fail and alert me?

Second, is my import not finding the file or something to make it not work? my package.json looks like this

    {
  "name": "myapp",
  "private": true,
  "scripts": {
    "start": "meteor run"
  },
  "dependencies": {
    "material-ui": "^0.15.0",
    "meteor-node-stubs": "~0.2.0",
    "react": "^15.0.2",
    "react-addons-pure-render-mixin": "^15.0.1",
    "react-datepicker": "^0.27.0",
    "react-dom": "^15.0.2",
    "react-mounter": "^1.2.0",
    "react-s-alert": "^1.1.4",
    "react-tap-event-plugin": "^1.0.0"
  },
  "devDependencies": {
    "enzyme": "^2.3.0",
    "react-addons-test-utils": "^15.1.0"
  }
}

and my packages looks like this

# edgee:slingshot                         # Send files to storage service.
# peerlibrary:aws-sdk                     # Amazon SDK for S3/EC2/etc...


# CORE PACKAGES
meteor-base                               # Meteor platform
mobile-experience                         # Mobile Optimizations
logging                                   # Meteor internal logging
ejson                                     # Extends JSON Types
tracker                                   # Reactive Data Sources
email                                     # Send emails
accounts-password                         # Authentication for users.
es5-shim                                  # ECMAScript 5 compatibility for older browsers.
ecmascript                                # Enable ECMAScript2015+ syntax
standard-minifier-css                     # CSS Minification
standard-minifier-js                      # Javascript Minification
static-html                               # Adds global head tag
reload                                    # Active reload
react-meteor-data                         # Used for react data mixins

stevezhu:lodash                           # Javascript utility library.
momentjs:moment                           # Date library for Javascript.
johnantoni:meteor-normalize               # normalizes css
fourseven:scss                            # SASS stylesheets.
fortawesome:fontawesome                   # Icons.
natestrauser:animate-css                  # Animations using CSS.
mongo                                     # Mongo DB
aldeed:collection2                        # Schemas and validations for database collections.
dburles:collection-helpers                # Create data helpers in ./lib available to client and server.
meteortoys:allthings                      # A number of helpers for deveopment. Activate with control+m
kadira:flow-router                        # Router.
mystor:device-detection                   # Detect device user is using.
semantic:ui-css
practicalmeteor:mocha
xolvio:cleaner
dburles:factory

So I have it installed.


#2

I failed to look at the console of my browser before, now that I am i’m getting this error:

Does anyone have any idea?


#3

Here is a link to my stack overflow question now…


#4

I solved it by doing a meteor update. Bam.