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

Add Javascript test line numbers #74

Merged
merged 2 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Current Spec File",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/node_modules/.bin/mochapack",
"args": [
"--webpack-config", "config/webpack/test.js",
"--require", "spec/javascript/setup.js",
"--timeout", "999999",
"--colors",
"${file}"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Mocha All JS Specs",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/node_modules/.bin/mochapack",
"args": [
"--webpack-config", "config/webpack/test.js",
"--require", "spec/javascript/setup.js",
"--timeout", "999999",
"--colors",
"spec/javascript/**/*.spec.js"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am looking forward to sysgears/mochapack#63 being resolved so that this file can reference a script in package.json instead of the args here potentially getting out of sync

],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
12 changes: 10 additions & 2 deletions config/webpack/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'test'
process.env.RAILS_ENV = process.env.RAILS_ENV || 'test'

const environment = require('./environment')
const nodeExternals = require('webpack-node-externals');

const babelLoader = environment.loaders.get('babel')
babelLoader.include.push(babelLoader.include[0].concat('../../test'))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be necessary anymore 🤷
I assume #71 made the difference

environment.config.merge({
output: {
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]'
},
mode: 'development',
externals: [nodeExternals()],
Copy link
Collaborator Author

@h-m-m h-m-m Apr 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my machine, this line sped up compilation time from 2.51s to 1.38s. Though I think it was closer to 0.84s as of a day or two ago (before adding source maps)

devtool: 'inline-cheap-module-source-map'
})

module.exports = environment.toWebpackConfig()
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
"mocha-junit-reporter": "^1.23.3",
"mochapack": "^1.1.15",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
"webpack-dev-server": "^3.10.3",
"webpack-node-externals": "^1.7.2"
},
"scripts": {
"test": "mochapack --webpack-config config/webpack/test.js --require test/setup.js test/**/*.spec.js"
"test": "mochapack --webpack-config config/webpack/test.js --require spec/javascript/setup.js --colors 'spec/javascript/**/*.spec.js'"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the quotes around the glob pattern, it's possible for some wonky shell interpolation to kick in instead of letting mocha handle it

}
}
File renamed without changes.
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8089,6 +8089,11 @@ webpack-log@^2.0.0:
ansi-colors "^3.0.0"
uuid "^3.3.2"

webpack-node-externals@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/webpack-node-externals/-/webpack-node-externals-1.7.2.tgz#6e1ee79ac67c070402ba700ef033a9b8d52ac4e3"
integrity sha512-ajerHZ+BJKeCLviLUUmnyd5B4RavLF76uv3cs6KNuO8W+HuQaEs0y0L7o40NQxdPy5w0pcv8Ew7yPUAQG0UdCg==

webpack-sources@^1.0.0, webpack-sources@^1.0.1, webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"
Expand Down