Giter Club home page Giter Club logo

alt-example-tests's People

Contributors

jdlehman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

alt-example-tests's Issues

Tests do not run

Just cloned the repo, ran npm install and tried running npm run test. On node 0.12.7 and 4.1.0

13:37 $ npm run test

> [email protected] test /Users/jamie.lesouef/Projects/tutorials/alt-example-tests
> karma start

WARN [watcher]: Pattern "/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/sinon/lib/../pkg/sinon.js" does not match any file.
WARN [preprocess]: Can not load "webpack"!
  TypeError: this.emitter.refreshFiles is not a function
    at Plugin.notifyKarmaAboutChanges (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/karma-webpack/index.js:108:15)
    at Plugin.<anonymous> (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/karma-webpack/index.js:72:9)
    at Compiler.applyPlugins (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/webpack/node_modules/tapable/lib/Tapable.js:26:37)
    at Watching._done (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/webpack/lib/Compiler.js:78:17)
    at Watching.<anonymous> (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/webpack/lib/Compiler.js:61:18)
    at Compiler.emitRecords (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/webpack/lib/Compiler.js:282:37)
    at Watching.<anonymous> (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/webpack/lib/Compiler.js:58:19)
    at /Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/webpack/lib/Compiler.js:275:11
    at Compiler.applyPluginsAsync (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/webpack/node_modules/tapable/lib/Tapable.js:60:69)
    at Compiler.afterEmit (/Users/jamie.lesouef/Projects/tutorials/alt-example-tests/node_modules/webpack/lib/Compiler.js:272:8)
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket -j6R1p7Jh4_ui5eHRtZn with id 69023428
PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
  SyntaxError: Parse error
  at /Users/jamie.lesouef/Projects/tutorials/alt-example-tests/test/actions/PetActions_test.js:1
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.025 secs / 0 secs)

npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test"
npm ERR! node v4.1.0
npm ERR! npm  v2.14.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test: `karma start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script 'karma start'.
npm ERR! This is most likely a problem with the alt-example-tests package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     karma start
npm ERR! You can get their info via:
npm ERR!     npm owner ls alt-example-tests
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/jamie.lesouef/Projects/tutorials/alt-example-tests/npm-debug.log

Alt Dispatch Never Fires

So I'm learning how to test Alt Actions (and React components), and followed your simple, straightforward example, but can't get it to work as expected. My version is somewhat simplified:

import alt from '../../utils/alt'
import Actions from '../../actions/Foo'
import sinon from 'sinon'

// using [sinon](http://sinonjs.org/docs/) for spying

describe('Actions', function() {
    beforeEach(function() {
        this.dispatcherSpy = sinon.spy(alt.dispatcher, 'dispatch')
    })

    afterEach(function() {
        // clean up our sinon spy so we do not affect other tests
        alt.dispatcher.dispatch.restore()
    })

    describe('#testList', function() {
        it('dispatches correct data', function() {
            // fire the action
            Actions.get({id:"1234"})
            // use our spy to see what payload the dispatcher was called with
            // this lets us ensure that the expected payload was fired
            var dispatcherArgs = this.dispatcherSpy.args[0]
            var firstArg = dispatcherArgs[0]
            console.log("TESTING", this.dispatcherSpy.calledOnce)

            expect(firstArg && firstArg.action).toBe(Actions.GET)
            expect(firstArg.data).toEqual({id:"1234"})
      })
  })
})

It appears that the dispatcherSpy never gets called, even though it appears that it should when the Alt action Get fires. Instead I get the error:

SourceMap position not found for trace: TypeError: undefined is not an object (evaluating 'dispatcherArgs[0]')

or if I comment out the two lines above the console.log, the log prints false confirming that the dispatcher never gets called. Any ideas?

Tests don't run on jspm/jasmine setup

Hi,

I am working on application using Alt and was trying to setup tests based on this repo. I tried to setup the tests in exactly the same way but in jspm/karma/jasmine setup, but wasn't able to make them pass. Then, I copied pasted your code and tried to run the tests in my setup but surprisingly even they didn't work. I have setup a repository with the test on github here.

Probably I am doing something stupid, but I have spend hours on this and couldn't find the problem. I would appreciate any help on this.

Thanks,
Abhi.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.