Skip to content

Commit

Permalink
added nodeResolutionAllowJs test (will fail initially)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyreilly committed Oct 17, 2017
1 parent b182a65 commit a504b11
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/execution-tests/nodeResolutionAllowJs/karma.conf.js
@@ -0,0 +1,46 @@
/* eslint-disable no-var, strict */
'use strict';
var path = require('path');
var webpack = require('webpack');
var webpackConfig = require('./webpack.config.js');
var reporterOptions = require('../../reporterOptions');

module.exports = function(config) {
config.set({
browsers: [ 'ChromeHeadless' ],

files: [
// This loads all the tests
'main.js'
],

port: 9876,

frameworks: [ 'jasmine' ],

logLevel: config.LOG_INFO, //config.LOG_DEBUG

preprocessors: {
'main.js': [ 'webpack', 'sourcemap' ]
},

webpack: {
devtool: 'inline-source-map',
module: webpackConfig.module,
resolve: webpackConfig.resolve,

// for test harness purposes only, you would not need this in a normal project
resolveLoader: webpackConfig.resolveLoader
},

webpackMiddleware: {
quiet: true,
stats: {
colors: true
}
},

// reporter options
mochaReporter: reporterOptions
});
};
2 changes: 2 additions & 0 deletions test/execution-tests/nodeResolutionAllowJs/main.js
@@ -0,0 +1,2 @@
const testsContext = require.context('./', true, /\.tests\.ts(x?)$/);
testsContext.keys().forEach(testsContext);
11 changes: 11 additions & 0 deletions test/execution-tests/nodeResolutionAllowJs/package.json
@@ -0,0 +1,11 @@
{
"name": "import-code-splitting",
"version": "1.0.0",
"main": "index.js",
"devDependencies": {
"@types/jasmine": "^2.5.35"
},
"dependencies": {
"date-fns": "2.0.0-alpha.1"
}
}
5 changes: 5 additions & 0 deletions test/execution-tests/nodeResolutionAllowJs/src/app.ts
@@ -0,0 +1,5 @@
import { format, parse} from "date-fns";

export function thisShouldNotError() {
return format(new Date(), "dd-MM-yyyy");
}
7 changes: 7 additions & 0 deletions test/execution-tests/nodeResolutionAllowJs/test/app.tests.ts
@@ -0,0 +1,7 @@
import * as submodule from '../src/app';

describe("app", () => {
it("thisShouldNotError returns something", () => {
expect(submodule.thisShouldNotError()).not.toBe(undefined as any);
});
});
9 changes: 9 additions & 0 deletions test/execution-tests/nodeResolutionAllowJs/tsconfig.json
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"noEmitOnError": true,
"module": "esnext",
"moduleResolution": "node",
"allowJs": true,
"strict": true
}
}
19 changes: 19 additions & 0 deletions test/execution-tests/nodeResolutionAllowJs/webpack.config.js
@@ -0,0 +1,19 @@
var path = require('path')

module.exports = {
entry: './app.ts',
output: {
filename: 'bundle.js'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader' }
]
}
}

// for test harness purposes only, you would not need this in a normal project
module.exports.resolveLoader = { alias: { 'ts-loader': path.join(__dirname, "../../../index.js") } }
11 changes: 11 additions & 0 deletions test/execution-tests/nodeResolutionAllowJs/yarn.lock
@@ -0,0 +1,11 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@types/jasmine@^2.5.35":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.6.0.tgz#997b41a27752b4850af2683bc4a8d8222c25bd02"

date-fns@2.0.0-alpha.1:
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.1.tgz#f45e477cf3414269d97fb1aae899035f3b308474"

0 comments on commit a504b11

Please sign in to comment.