Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phantom 2.1 - Tests Fail on Object.assign, ember-resolver missing, and more - All Works in Chrome #273

Closed
josiahbryan opened this issue May 22, 2017 · 4 comments

Comments

@josiahbryan
Copy link

josiahbryan commented May 22, 2017

Hey everyone!

Got a REALLY Weird problem that I've spent the last several hours trying to Google for answers - with no luck.

Okay, so here's the TL;DR of it all:

  • ember test --server - All tests run fine in the browser but console reports tests fail in Phantom

Running npm test (or ember test) from the console produces a myrid of errors, all with very odd Phantom errors, such as the following:

  • "undefined is not a function" (re Object.assign)
  • "Could not find module 'ember-resolver'"
  • "The tests file was not loaded"
  • "you must set a resolver with `testResolver.set(resolver)"

What I've tried so far:

  • Runs fine in browser - so it's not a failure in my tests - I don't think
  • Tried installing es6-shim (and app.import'ing it in the cli build file) - no luck there
  • Did bower clear cache && bower update && bower install - no luck there either

Any ideas, anyone? Thanks in advance for the help!


Here's the versions I'm testing with:

$ npm ls ember-test-helpers
└─┬ ember-cli-qunit@3.1.2
  └─┬ ember-qunit@2.1.3
    └── ember-test-helpers@0.6.3 

And here's my packages I'm using from packages.json:

  "devDependencies": {
    "bootstrap": "^4.0.0-alpha.6",
    "broccoli-asset-rev": "^2.4.5",
    "ember-ajax": "^2.4.1",
    "ember-bootstrap-4": "^0.1.2",
    "ember-cli": "2.12.2",
    "ember-cli-app-version": "^2.0.0",
    "ember-cli-babel": "^5.1.7",
    "ember-cli-dependency-checker": "^1.3.0",
    "ember-cli-eslint": "^3.0.0",
    "ember-cli-htmlbars": "^1.1.1",
    "ember-cli-htmlbars-inline-precompile": "^0.3.6",
    "ember-cli-inject-live-reload": "^1.4.1",
    "ember-cli-mirage": "^0.3.1",
    "ember-cli-qunit": "^3.1.0",
    "ember-cli-sass": "^6.1.3",
    "ember-cli-shims": "^1.0.2",
    "ember-cli-sri": "^2.1.0",
    "ember-cli-uglify": "^1.2.0",
    "ember-data": "^2.12.0",
    "ember-data-feathers": "0.0.5",
    "ember-export-application-global": "^1.0.5",
    "ember-load-initializers": "^0.6.0",
    "ember-resolver": "^2.0.3",
    "ember-source": "~2.12.0",
    "loader.js": "^4.2.3"
  },

And, finally, the exact output from the npm test command:

[josiah@JosiahsLaptop client]$ npm test

> filos@0.1.0 test /path/redacted/client
> ember test

Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
cleaning up...
Built project successfully. Stored in "/path/redacted/client/tmp/class-tests_dist-0rQSA4in.tmp".
not ok 1 PhantomJS 2.1 - Global error: TypeError: undefined is not a function (evaluating 'Object.assign') at http://localhost:7357/assets/vendor.js, line 137860
    ---
        Log: |
            { type: 'error',
              text: 'TypeError: undefined is not a function (evaluating \'Object.assign\') at http://localhost:7357/assets/vendor.js, line 137860\n' }
    ...
not ok 2 PhantomJS 2.1 - Global error: Error: Could not find module `ember-resolver` imported from `filos/resolver` at http://localhost:7357/assets/vendor.js, line 237
    ---
        Log: |
            { type: 'error',
              text: 'Error: Could not find module `ember-resolver` imported from `filos/resolver` at http://localhost:7357/assets/vendor.js, line 237\n' }
    ...
not ok 3 PhantomJS 2.1 - Global error: Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 16574
    ---
        Log: |
            { type: 'error',
              text: 'Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 16574\n' }
    ...
not ok 4 PhantomJS 2.1 - global failure
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            http://localhost:7357/assets/vendor.js:237
        message: >
            Error: Could not find module `ember-resolver` imported from `filos/resolver`
        Log: |
    ...
not ok 5 PhantomJS 2.1 - global failure
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            http://localhost:7357/assets/vendor.js:16574
        message: >
            Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".
        Log: |
    ...
ok 6 PhantomJS 2.1 - ESLint | mirage: mirage/config.js
ok 7 PhantomJS 2.1 - ESLint | mirage: mirage/models/account.js
ok 8 PhantomJS 2.1 - ESLint | mirage: mirage/models/checkin.js
ok 9 PhantomJS 2.1 - ESLint | mirage: mirage/models/contact.js
ok 10 PhantomJS 2.1 - ESLint | mirage: mirage/models/user.js
ok 11 PhantomJS 2.1 - ESLint | mirage: mirage/scenarios/default.js
ok 12 PhantomJS 2.1 - ESLint | mirage: mirage/serializers/application.js
ok 13 PhantomJS 2.1 - ESLint | app: adapters/application.js
ok 14 PhantomJS 2.1 - ESLint | app: app.js
ok 15 PhantomJS 2.1 - ESLint | app: components/checkin-list.js
ok 16 PhantomJS 2.1 - ESLint | app: components/contact-list-row.js
ok 17 PhantomJS 2.1 - ESLint | app: components/contact-list.js
ok 18 PhantomJS 2.1 - ESLint | app: models/account.js
ok 19 PhantomJS 2.1 - ESLint | app: models/checkin.js
ok 20 PhantomJS 2.1 - ESLint | app: models/contact.js
ok 21 PhantomJS 2.1 - ESLint | app: models/user.js
ok 22 PhantomJS 2.1 - ESLint | app: resolver.js
ok 23 PhantomJS 2.1 - ESLint | app: router.js
ok 24 PhantomJS 2.1 - ESLint | app: routes/contacts.js
ok 25 PhantomJS 2.1 - ESLint | app: routes/index.js
ok 26 PhantomJS 2.1 - ESLint | app: serializers/application.js
ok 27 PhantomJS 2.1 - ESLint | app: transforms/object.js
ok 28 PhantomJS 2.1 - ESLint | app: utils/models/autosave-model-mixin.js
not ok 29 PhantomJS 2.1 - Integration | Component | checkin list: it renders
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            _default@http://localhost:7357/assets/test-support.js:8413:80
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:5169:11
        message: >
            before failed on it renders: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 30 PhantomJS 2.1 - Integration | Component | contact list row: it renders
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            _default@http://localhost:7357/assets/test-support.js:8413:80
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it renders: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 31 PhantomJS 2.1 - Integration | Component | contact list: it renders
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            _default@http://localhost:7357/assets/test-support.js:8413:80
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it renders: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
ok 32 PhantomJS 2.1 - ESLint | tests: helpers/destroy-app.js
ok 33 PhantomJS 2.1 - ESLint | tests: helpers/module-for-acceptance.js
ok 34 PhantomJS 2.1 - ESLint | tests: helpers/resolver.js
ok 35 PhantomJS 2.1 - ESLint | tests: helpers/start-app.js
ok 36 PhantomJS 2.1 - ESLint | tests: integration/components/checkin-list-test.js
ok 37 PhantomJS 2.1 - ESLint | tests: integration/components/contact-list-row-test.js
ok 38 PhantomJS 2.1 - ESLint | tests: integration/components/contact-list-test.js
ok 39 PhantomJS 2.1 - ESLint | tests: test-helper.js
ok 40 PhantomJS 2.1 - ESLint | tests: unit/adapters/application-test.js
ok 41 PhantomJS 2.1 - ESLint | tests: unit/models/account-test.js
ok 42 PhantomJS 2.1 - ESLint | tests: unit/models/checkin-test.js
ok 43 PhantomJS 2.1 - ESLint | tests: unit/models/contact-test.js
ok 44 PhantomJS 2.1 - ESLint | tests: unit/models/user-test.js
ok 45 PhantomJS 2.1 - ESLint | tests: unit/routes/contacts-test.js
ok 46 PhantomJS 2.1 - ESLint | tests: unit/routes/index-test.js
ok 47 PhantomJS 2.1 - ESLint | tests: unit/transforms/object-test.js
not ok 48 PhantomJS 2.1 - Unit | Adapter | application: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it exists: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 49 PhantomJS 2.1 - Unit | Model | account: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            _default@http://localhost:7357/assets/test-support.js:8944:80
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it exists: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 50 PhantomJS 2.1 - Unit | Model | checkin: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            _default@http://localhost:7357/assets/test-support.js:8944:80
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it exists: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 51 PhantomJS 2.1 - Unit | Model | contact: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            _default@http://localhost:7357/assets/test-support.js:8944:80
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it exists: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 52 PhantomJS 2.1 - Unit | Model | user: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            _default@http://localhost:7357/assets/test-support.js:8944:80
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it exists: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 53 PhantomJS 2.1 - Unit | Route | contacts: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it exists: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 54 PhantomJS 2.1 - Unit | Route | index: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it exists: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...
not ok 55 PhantomJS 2.1 - Unit | Transform | object: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            getResolver@http://localhost:7357/assets/test-support.js:9322:83
            _default@http://localhost:7357/assets/test-support.js:9027:96
            before@http://localhost:7357/assets/test-support.js:7822:33
            callHook@http://localhost:7357/assets/test-support.js:3892:26
            runHook@http://localhost:7357/assets/test-support.js:3886:15
            advance@http://localhost:7357/assets/test-support.js:3518:26
            begin@http://localhost:7357/assets/test-support.js:5209:27
            http://localhost:7357/assets/test-support.js:4403:11
        message: >
            before failed on it exists: you must set a resolver with `testResolver.set(resolver)`
        Log: |
    ...

1..55
# tests 55
# pass  39
# skip  0
# fail  16
@josiahbryan
Copy link
Author

Sorry to bother you all, but does anyone have any ideas? I'd really love to have Phantom working so I can automate my build testing ... any ideas? :-)

@stefanpenner
Copy link
Member

stefanpenner commented May 24, 2017

It looks like you may need an Object.assign polyfil

Question: http://localhost:7357/assets/vendor.js, line 137860 what is at this location? Just curious which library is introducing this, that way we can make it phantom compatible without a polyfil (ember and default ember-cli apps are tested against phantom so we should be fine)

@josiahbryan
Copy link
Author

Hmmm....something like https://www.npmjs.com/package/phantomjs-polyfill-object-assign ?

Re: vendor.js - since that's a generated file, and I've done a ton of updates to the project, I'm sure that line number will be have changed. I'll add the polyfill in and try it right now and see if the same error happens and report back ASAP

@josiahbryan
Copy link
Author

josiahbryan commented May 24, 2017

Mmmmmmmmmmm kay!

Wow, that actually worked. I had to put the following in my tests/index.html file, even after installing phantomjs-polyfill-object-assign because I couldn't figure out how to get Phantom to load the module. However, copying the code from that module and putting it in index.html fixed everything and now "ember test" runs perfectly from the command line - thanks, @stefanpenner !

Here's what I added in a <script>...</script> tag to the <head> of test/index.html:

        // This polyfill from https://www.npmjs.com/package/phantomjs-polyfill-object-assign
	//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
	if (typeof Object.assign != 'function') {
	  (function () {
	    Object.assign = function (target) {
	      'use strict';
	      if (target === undefined || target === null) {
	        throw new TypeError('Cannot convert undefined or null to object');
	      }

	      var output = Object(target);
	      for (var index = 1; index < arguments.length; index++) {
	        var source = arguments[index];
	        if (source !== undefined && source !== null) {
	          for (var nextKey in source) {
	            if (source.hasOwnProperty(nextKey)) {
	              output[nextKey] = source[nextKey];
	            }
	          }
	        }
	      }
	      return output;
	    };
	  })();
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants