jeudi 1 septembre 2016

Angular2 test spec not running correctly

I am currently writing some test specs for my Angular2 Typescript application. I have a couple of scripts working but at as it stands when my test contains a 'beforeEach' Jasmine call the function does not work correctly.

Here is the spec file in question:

import { Uppercase } from '../../pipes/uppercase-pipe';

/**
 *  MyUppercasePipe
 *      transforms "abc" to "ABC"
 *      transforms "abc def" to "ABC DEF"
 *      leaves "ABC DEF" unchanged
 */
describe("Uppercase pipe filter", function() {

    let pipe: Uppercase;

    beforeEach(() => {
        pipe = new Uppercase();            
    });

    it('transforms "abc" to "ABC"', () => {
        expect(pipe.transform('abc')).toEqual('ABC');
    });

    it('transforms "abc def" to "ABC DEF"', () => {
        expect(pipe.transform('abc def')).toEqual('ABC DEF');
    });
    it('leaves "ABC DEF" unchanged', () => {
        expect(pipe.transform('ABc DEF')).toEqual('ABC DEF');
    });*

});

The spec is imported in the unit-tests.html file as shown here:

    <script>
        // #2. Configure systemjs to use the .js extension
        //     for imports from the app folder
        System.config({
            packages: {
                app: {
                    defaultExtension: 'js'
                }
            }
        });

        Promise.all([
            System.import('app/tests/classes/Category.spec'),
            System.import('app/tests/classes/Product.spec'),
            System.import('app/tests/pipes/uppercase.spec'),
            System.import('app/tests/pipes/string-pipe.spec')
        ]).then(window.load)
                .catch(console.error.bind(console));

    </script>

I have removed the beforeEach and added in a simple test in it's place and the file runs fine when this happens.

Can anyone see why this particular test spec may not be running? There is no trace of it in the test runner when run it.

Aucun commentaire:

Enregistrer un commentaire