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

ESLint test generator only works with QUnit #105

Closed
nucleartide opened this issue Aug 11, 2016 · 5 comments
Closed

ESLint test generator only works with QUnit #105

nucleartide opened this issue Aug 11, 2016 · 5 comments

Comments

@nucleartide
Copy link

nucleartide commented Aug 11, 2016

The docs say that things should "Just Work", but that doesn't seem to be the case when I'm using ember-cli-eslint together with ember-cli-mocha. It seems to me like the default test generator only returns QUnit tests for linting, never Mocha tests.

Using that as an example, I wrote a test generator for Mocha:

var jsStringEscape = require('js-string-escape')
var EmberApp = require('ember-cli/lib/broccoli/ember-app')

function render(errors) {
  if (!errors) return ''
  return errors.map(err => `${err.line}:${err.column} - ${err.message} (${err.ruleId})`).join(jsStringEscape('\n'))
}

function eslintTestGenerator(relativePath, errors) {
  const pass = !errors || errors.length === 0
  const errs = render(errors)
  return `
    import Chai from 'chai'
    import { describe, it } from 'mocha'

    const { assert } = Chai

    describe('${relativePath}', function() {
      it('should pass ESLint', function() {
        assert.ok(${pass}, '${relativePath + ' should pass ESLint.' + jsStringEscape('\n\n' + errs + '\n\n')}')
      })
    })
  `
}

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    eslint: {
      testGenerator: eslintTestGenerator
    }
  })
}

I'm not entirely sure how this could be fixed - should the test generator functions be moved to their respective Ember addons (ember-cli-qunit and ember-cli-mocha)? This was very, very frustrating to see upon installing ember-cli-mocha.

(Also, the test generator function above requires Node 4+, for those ES6 features.)

@alexlafroscia
Copy link
Collaborator

alexlafroscia commented Aug 12, 2016

Which version of ember-cli are you using? With the lastest versions of ember-cli, ember-cli-eslint and ember-cli-mocha it will all "just work" like it should. Update those dependencies if you're seeing issues and it should take care of things.

@nucleartide
Copy link
Author

nucleartide commented Aug 12, 2016

Just tried on a fresh project, see the pic below. Here's the repo: link.

It doesn't bombard me with loads of linting errors like it did in my app (since my app has lots of files 😄 ) , but it does still generate JSHint test cases for whatever reason.

node version: v4.2.2
npm version: 2.14.7
ember-cli version: 2.7.0
ember-cli-mocha version: 0.10.4
ember-cli-eslint version: 1.7.0

screenshot 2016-08-12 14 46 05

@alexlafroscia
Copy link
Collaborator

alexlafroscia commented Aug 12, 2016

Did you also uninstall ember-cli-jshint? It will override the eslint config and you'll see that output. This will be fixed once #91 is pulled in, which will uninstall jshint and the config files for it on installation of ember-cli-eslint. For some reason, if both are present, Mocha seems to take JSHint over ESLint (not sure if by an explicit preference or just the order that things are loaded).

@nucleartide
Copy link
Author

Ah, whoops! That is it, I must have been confused by my commit message.

Amazingly, it also works in my current app if I comment out my custom test generator. Maybe yesterday was just a bad day...

Thanks for the help! 😄

@alexlafroscia
Copy link
Collaborator

alexlafroscia commented Aug 12, 2016

Yeah, it looks like jshint is still in there.

Not problem! Happy to. Actually just had this same problem at work with a new app, so I recognized the issue.

Turbo87 pushed a commit that referenced this issue Nov 9, 2018
Bumps [qunit-dom](https://github.com/simplabs/qunit-dom) from 0.7.1 to 0.8.0.
<details>
<summary>Changelog</summary>

*Sourced from [qunit-dom's changelog](https://github.com/simplabs/qunit-dom/blob/master/CHANGELOG.md).*

> ## v0.8.0 (2018-09-06)
> 
> #### 💥 Breaking Change
> * [#105](https://github-redirect.dependabot.com/simplabs/qunit-dom/pull/105) Collapse whitespace for `includesText` assertion ([[**brookjordan**](https://github.com/brookjordan)](https://github.com/brookjordan))
> * [#126](https://github-redirect.dependabot.com/simplabs/qunit-dom/pull/126) Update Node version requirement to `6.* || 8.* || >= 10.*` ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> * [#117](https://github-redirect.dependabot.com/simplabs/qunit-dom/pull/117) Bump broccoli-merge-trees from 2.0.0 to 3.0.1 ([[**dependabot**](https://github.com/dependabot)[bot]](https://github.com/apps/dependabot))
> 
> #### 📝 Documentation
> * [#103](https://github-redirect.dependabot.com/simplabs/qunit-dom/pull/103) README: Add `import` documentation ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> 
> #### Committers: 2
> - Brook Jordan ([[**brookjordan**](https://github.com/brookjordan)](https://github.com/brookjordan))
> - Tobias Bieniek ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
</details>
<details>
<summary>Commits</summary>

- [`a908f3c`](mainmatter/qunit-dom@a908f3c) v0.8.0
- [`87c3dcf`](mainmatter/qunit-dom@87c3dcf) Update Changelog
- [`fbdaa18`](mainmatter/qunit-dom@fbdaa18) Bump broccoli-merge-trees from 2.0.0 to 3.0.1 ([#117](https://github-redirect.dependabot.com/simplabs/qunit-dom/issues/117))
- [`43f8d70`](mainmatter/qunit-dom@43f8d70) Merge pull request [#126](https://github-redirect.dependabot.com/simplabs/qunit-dom/issues/126) from Turbo87/bump-node-req
- [`519815b`](mainmatter/qunit-dom@519815b) Update Node version requirement to `6.* || 8.* || >= 10.*`
- [`92223aa`](mainmatter/qunit-dom@92223aa) Bump rollup from 0.49.2 to 0.65.0 ([#123](https://github-redirect.dependabot.com/simplabs/qunit-dom/issues/123))
- [`56c0f7e`](mainmatter/qunit-dom@56c0f7e) Merge pull request [#124](https://github-redirect.dependabot.com/simplabs/qunit-dom/issues/124) from simplabs/dependabot/npm_and_yarn/lerna-changelog...
- [`140708a`](mainmatter/qunit-dom@140708a) Bump lerna-changelog from 0.6.0 to 0.8.0
- [`0f7e252`](mainmatter/qunit-dom@0f7e252) Bump babel-plugin-transform-es2015-modules-commonjs from 6.26.0 to 6.26.2 ([#121](https://github-redirect.dependabot.com/simplabs/qunit-dom/issues/121))
- [`62c7456`](mainmatter/qunit-dom@62c7456) Bump ember-cli-qunit from 4.0.1 to 4.3.2 ([#122](https://github-redirect.dependabot.com/simplabs/qunit-dom/issues/122))
- Additional commits viewable in [compare view](mainmatter/qunit-dom@v0.7.1...v0.8.0)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=qunit-dom&package-manager=npm_and_yarn&previous-version=0.7.1&new-version=0.8.0)](https://dependabot.com/compatibility-score.html?dependency-name=qunit-dom&package-manager=npm_and_yarn&previous-version=0.7.1&new-version=0.8.0)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

Dependabot will **not** automatically merge this PR because this dependency is pre-1.0.0.

---

**Note:** This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

You can always request more updates by clicking `Bump now` in your [Dependabot dashboard](https://app.dependabot.com).

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants