Created
October 30, 2018 11:59
-
-
Save limptwiglet/75a289278bb00d423007f0925557ba6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { describe, it } from 'mocha'; | |
import { expect } from 'chai'; | |
import Nav from '../../src/components/Nav.html'; | |
import { getByText } from 'dom-testing-library'; | |
describe('first test', () => { | |
it('should be testable', () => { | |
let nav = new Nav({ | |
target: document.body | |
}); | |
expect(getByText(document, 'about')).to.not.be.undefined; | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
"test": "mocha-webpack --require test/setup.js --webpack-config test/webpack.config-test.js \"test/integration/**/*.test.js\"" | |
.... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('jsdom-global')(); | |
const { JSDOM } = require('jsdom'); | |
const document = new JSDOM('<html><head></head><body></body></html>'); | |
global.navigator = { | |
userAgent: 'node.js' | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack'); | |
const nodeExternals = require('webpack-node-externals'); | |
const mode = process.env.NODE_ENV; | |
const dev = mode === 'development'; | |
module.exports = { | |
mode, | |
target: 'node', | |
externals: [nodeExternals()], | |
resolve: { | |
extensions: ['.js', '.json', '.html'], | |
mainFields: ['svelte', 'module', 'browser', 'main'] | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.html$/, | |
use: { | |
loader: 'svelte-loader', | |
options: { | |
dev, | |
hydratable: true, | |
hotReload: true, | |
preprocess: require('svelte-preprocess')({ transformers: { stylus: true }}) | |
} | |
} | |
} | |
] | |
}, | |
plugins: [ | |
dev && new webpack.HotModuleReplacementPlugin(), | |
new webpack.DefinePlugin({ | |
'process.browser': true, | |
'process.env.NODE_ENV': JSON.stringify(mode) | |
}), | |
].filter(Boolean) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment