Closed thenickcox closed 8 years ago
Can not ensure where is the major issue, but here are some points:
Notification
seems to be a react component, it will be better to change Notifications = require './common/notifications'
into Notifications = require './common/notifications.jsx'
or .cjsx
.cjsx: /\.csjx$/
into cjsx: /\.cjsx$/
Thanks for the quick response! I fixed the transpile
hash, but it's still saying Cannot find module './common/notifications'
. Regarding the adding of the extension to the require
statement, isn't that what omitExt
allows me to do? To leave the extension off in the require
statement? Adding the extension to the require
statement makes it work, but I have about 60 components in my app that work currently without the extension in the require statement, and the docs made it seem like that was possible: if you wanna omit file ext when require(), put an array of file exts here.
This also leads to the question, why is this not recommended as you say in the comment on the omitExt
line?
it should be a bug, I will test more on it then try to fix it.
Now the bug should be fixed and the new version 0.3.7 released for this, please try it, thanks.
@zordius Thanks a lot for the update. I updated to 0.3.7 and am still getting the error that it cannot find a module relatively.
For reference, here are my configs:
#--------------------------------------------------------
# Requirements
#--------------------------------------------------------
gulp = require 'gulp'
plugins = require('gulp-load-plugins')()
#--------------------------------------------------------
# Coverage
#--------------------------------------------------------
gulp.task("js_coverage", require('gulp-jsx-coverage').createTask(
src: [
'test/components/**/*.coffee',
'app/assets/javascripts/*.coffee',
'app/assets/javascripts/utils/*.coffee',
'app/assets/javascripts/components/*.cjsx',
'app/assets/javascripts/components/**/*.cjsx',
'app/assets/javascripts/stores/*.coffee',
'app/assets/javascripts/actions/*.coffee',
'app/assets/javascripts/training/components/*.cjsx',
'app/assets/javascripts/training/actions/*.coffee',
'app/assets/javascripts/training/stores/*.coffee',
]
isparta: false
istanbul:
preserveComments: true
coverageVariable: '__MY_TEST_COVERAGE__',
exclude: /node_modules|test[0-9]/
transpile:
cjsx: /\.cjsx$/
omitExt: ['.cjsx']
coverage:
reporters: ['text-summary', 'json', 'lcov']
directory: 'js_coverage'
mocha:
reporter: 'spec'
coffee:
sourceMap: true
))
The first test in the test
directory is this:
require '../../testHelper'
ActivityTableRow = require '../../../app/assets/javascripts/components/activity/activity_table_row.cjsx'
ActivityTable = require '../../../app/assets/javascripts/components/activity/activity_table.cjsx'
CustomUtils = require '../../customUtils'
click = CustomUtils.click
describe 'ActivtyTableRow', ->
TestRow = ReactTestUtils.renderIntoDocument(
<ActivityTable
loading=false
activity={[{ key: '1', revision_score: 0, title: 'Foobar', courses: [{slug: 'cat'}, {slug: 'dog'}]}]}
headers={[{key: '1' }]}
noActivityMessage='Hello world'>
<ActivityTableRow
key={23948}
rowId=675818536
title='Selfie'
articleUrl='https://en.wikipedia.org/wiki/Selfie'
author='Wavelength'
talkPageLink='https://en.wikipedia.org/wiki/User_talk:Wavelength'
diffUrl='https://en.wikipedia.org/w/index.php?title=Selfie&diff=675818536&oldid=675437996'
revisionDateTime='2015/08/012 9:43 pm'
revisionScore=61
/>
</ActivityTable>
)
it 'renders a table row with activity-table-row class and closed class', ->
rows = ReactTestUtils.scryRenderedDOMComponentsWithTag(TestRow, 'tr')
# rows[0] is header row
expect(rows[1].className).to.eq 'activity-table-row closed'
it 'changes class open to class closed when state is_open', ->
row = ReactTestUtils.scryRenderedDOMComponentsWithClass(TestRow, 'activity-table-row')[0]
expect(row.className).to.eq('activity-table-row closed')
click(row).then (row) -> expect(row.className).to.eq('activity-table-row open')
That first require statement requires the ActivityTableRow
component. Here's the top of it, the require
statements, where this fails:
React = require 'react'
ActivityTableRow = require './activity_table_row'
TransitionGroup = require 'react-addons-css-transition-group'
Loading = require '../common/loading'
So when I run gulp js_coverage
, I get:
$ ./jscoverage !20058
[11:02:05] Requiring external module coffee-script/register
[11:02:06] Using gulpfile ~/projects/dashboard/gulpfile.coffee
[11:02:06] Starting 'js_coverage'...
[11:02:08] 'js_coverage' errored after 1.81 s
[11:02:08] Error in plugin 'gulp-mocha'
Message:
Cannot find module './activity_table_row'
Details:
code: MODULE_NOT_FOUND
Stack:
Error: Cannot find module './activity_table_row'
Sorry, it looks like my config was wrong. I changed
transpile:
cjsx: /\.cjsx$/
omitExt: ['.cjsx']
to
transpile:
cjsx:
include: /\.cjsx$/
omitExt: ['.cjsx']
Still working out some other errors, and I'll report back.
I can confirm that it gulp-jsx-coverage
now allows extension-less require
statements, and that it includes coverage for files that don't have tests.
Thanks a lot! :tada:
Here's my
app.cjsx
component:When I run the gulp task, it fails with this output:
Looks like the
moduleLoader
function inindex.js
isn't finding it. For reference, here is my gulp task:I get the error regardless of what I have under in the
transpile
hash. I also get this error for any other modules that arerequire
d relatively.