title: Frisby Functional Test standards
body: <p>I'm new to this and I have been searching for ways (or standards) to write proper functional tests but I still I have many unanswered questions. I'm using FrisbyJS to write functional tests for my NodeJS API application and <code>jasmine-node</code> to run them.</p>
  
  <p>I have gone through Frisby's documentation, but it wasn't fruitful for me.</p>
  
  <p>Here is a scenario:</p>
  
  <ul>
  <li>A guest can create a <code>User</code>. (No username duplication allowed, obviously)</li>
  <li>After creating a <code>User</code>, he can login. On successful login, he gets an Access-Token.</li>
  <li>A <code>User</code> can create a <code>Post</code>. Then a <code>Post</code> can have <code>Comment</code>, and so on...</li>
  <li>A <code>User</code> cannot be deleted once created. (Not from my NodeJS Application)</li>
  </ul>
  
  <p>What Frisby documentation says is, I should write a test within a test.</p>
  
  <p>For example (full-test.spec.js):</p>
  
  <pre><code>// Create User Test
  frisby.create('Create a `User`')
      .post('http://localhost/users', { ... }, {json: true})
      .expectStatus(200)
      .afterJSON(function (json) {
  
          // User Login Test
          frisby.create('Login `User`')
              .post('http://localhost/users/login', { ... }, {json: true})
              .expectStatus(200)
              .afterJSON(function (json) {
  
                  // Another Test (For example, Create a post, and then comment)
  
              })
              .toss();
  
      })
      .toss();
  </code></pre>
  
  <p>Is this the right way to write a functional test? I don't think so... It looks dirty.</p>
  
  <p>I want my tests to be modular. Separate files for each test. 
  If I create separate files for each test, then while writing a test for <code>Create Post</code>, I'll need a <code>User</code>'s Access-Token.</p>
  
  <p>To summarize, the question is: How should I write tests if things are dependent on each other?
  <code>Comment</code> is dependent on <code>Post</code>. <code>Post</code> is dependent on <code>User</code>.</p>