Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Document test process and/or fix tests #2

Closed
jfsiii opened this issue Oct 11, 2014 · 8 comments
Closed

Document test process and/or fix tests #2

jfsiii opened this issue Oct 11, 2014 · 8 comments

Comments

@jfsiii
Copy link

jfsiii commented Oct 11, 2014

Should the tests pass? If so, can you update the README to include testing instructions?

I planned on using this as the starting point for less-plugin-bower-import but stopped when I couldn't get the tests to pass. Here's what I did:

My first attempt, after cloning the repo:

> node test/index.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'less'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/jschulz/Sites/less-plugin-npm-import/test/index.js:1:74)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

I installed less (and added it as a dependency) then tried again:

>  node test/index.js

LESS - npm import

- npm-import/test: FAIL

module.js:340
    throw err;
          ^
Error: Cannot find module 'diff'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at diff (/Users/jschulz/Sites/less-plugin-npm-import/node_modules/less/test/less-test.js:153:9)
    at difference (/Users/jschulz/Sites/less-plugin-npm-import/node_modules/less/test/less-test.js:174:9)
    at /Users/jschulz/Sites/less-plugin-npm-import/node_modules/less/test/less-test.js:145:25
    at fs.js:271:14
    at Object.oncomplete (fs.js:107:15)

I looked at the test and saw it was using Less's tests, so I went to that directory, installed Less's dependencies and tried again:

> cd node_modules/less/
> npm install
<snip>
> cd -
/Users/jschulz/Sites/less-plugin-npm-import
> node test/index.js

LESS - npm import

- npm-import/test: FAIL
.comma-delimited {
  text-shadow: -1px -1px 1px red, 6px 5px 5px yellow;
  -moz-box-shadow: 0pt 0pt 2px rgba(255, 255, 255, 0.4) inset, 0pt 4px 6px rgba(255, 255, 255, 0.4) inset;
  -webkit-transform: rotate(0deg);
}
@font-face {
  font-family: Headline;
  unicode-range: U+??????, U+0???, U+0-7F, U+A5;
}
.other {
  -moz-transform: translate(0, 11em) rotate(-90deg);
  transform: rotateX(45deg);
}
.item[data-cra_zy-attr1b-ut3=bold] {
  font-weight: bold;
}
p:not([class*="lead"]) {
  color: black;
}
input[type="text"].class#id[attr=32]:not(1) {
  color: white;
}
div#id.class[a=1][b=2].class:not(1) {
  color: white;
}
ul.comma > li:not(:only-child)::after {
  color: white;
}
ol.comma > li:nth-last-child(2)::after {
  color: white;
}
li:nth-child(4n+1),
li:nth-child(-5n),
li:nth-child(-n+2) {
  color: white;
}
a[href^="http://"] {
  color: black;
}
a[href$="http://"] {
  color: black;
}
form[data-disabled] {
  color: black;
}
p::before {
  color: black;
}
#issue322 {
  -webkit-animation: anim2 7s infinite ease-in-out;
}
@-webkit-keyframes frames {
  0% {
    border: 1px;
  }
  5.5% {
    border: 2px;
  }
  100% {
    border: 3px;
  }
}
@keyframes fontbulger1 {
  to {
    font-size: 15px;
  }
  from,
  to {
    font-size: 12px;
  }
  0%,
  100% {
    font-size: 12px;
  }
}
.units {
  font: 1.2rem/2rem;
  font: 8vw/9vw;
  font: 10vh/12vh;
  font: 12vm/15vm;
  font: 12vmin/15vmin;
  font: 1.2ch/1.5ch;
}
@supports ( box-shadow: 2px 2px 2px black ) or
          ( -moz-box-shadow: 2px 2px 2px black ) {
  .outline {
    box-shadow: 2px 2px 2px black;
    -moz-box-shadow: 2px 2px 2px black;
  }
}
@-x-document url-prefix(""github.com"") {
  h1 {
    color: red;
  }
}
@viewport {
  font-size: 10px;
}
@namespace foo url(http://www.example.com);
foo|h1 {
  color: blue;
}
foo|* {
  color: yellow;
}
|h1 {
  color: red;
}
*|h1 {
  color: green;
}
h1 {
  color: green;
}
.upper-test {
  UpperCaseProperties: allowed;
}
@host {
  div {
    display: block;
  }
}
::distributed(input::placeholder) {
  color: #b3b3b3;
}
.shadow ^ .dom,
body ^^ .shadow {
  display: done;
}
:host(.sel .a),
:host-context(.sel .b),
.sel /deep/ .b,
::content .sel {
  type: shadow-dom;
}
 /deep/ b {¶
  c: 'd';
}
 /deep/ b[e] {
  f: 'g';
}
#issue2066 {
  background: url('/images/icon-team.svg') 0 0 / contain;
}


1 Failed, 0 passed

Better, but still broken. I'm not sure if it's me, the code, or some combination of the two.

@jonschlinkert
Copy link

still broken. I'm not sure if it's me, the code, or some combination of the two.

I might get this engraved on a plaque and nail it to my desk. Story of my life.

@lukeapage
Copy link
Member

I meant to put an issue in for this, sorry.

The problem is that to test an npm import, it needs a module to import less from - now I used less v2 - but I have specified with .npmignore not to include test files, so it was a short term thing.
Further, I got it working and then fixed a bug on the v2 branch which added some css to the css-3 test case - that meant that at the moment you would have to update the test/css/npm-import/css-3.css file to be the same as the css-3 file in less.

My current ideas for a long term way of testing are
a) a less-plugin-npm-import-test module just used for testing, including 1 less file.
b) getting the tests to write a folder into node_modules
c) picking a public module and keeping it at a static version (so the css won't change)

Any preferences?

You'll have the same problem with bower.

And I explained on the pull request why I don't want an optional dependency just yet..

Sorry things are in limbo, I only wrote this yesterday, I wasn't expecting someone to want it documented before the next day...

@lukeapage
Copy link
Member

went for (a) so I can test multiple scenarios without searching for arbitrary packages.

Fixed.

@lukeapage
Copy link
Member

? Really?!

@lukeapage
Copy link
Member

I was expecting a thanks for resolving both issues for you.

@jfsiii
Copy link
Author

jfsiii commented Oct 12, 2014

I apologize for escalating. Assuming you're OK with it, I'd like to put this behind us and concentrate on solving the task at hand.

Should less-plugin-bower-import also test against less-plugin-npm-import-test? If so, does less-plugin-npm-import-test need a bower.json? Is there a way to make a module (less-plugin-import-test?) which can be used for testing by multiple Less plugins?

@lukeapage
Copy link
Member

Tbh I don't know much about bower, but yes I could change it to be a
general less test package. Does bower just need a github/npm package with a
bower.json in?
I'd be happy to rename it and happy to pull into it whatever you need.

@jfsiii
Copy link
Author

jfsiii commented Oct 12, 2014

OK, cool. I'll test against that module for now and we can leave renaming/adding files for later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants