- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 600
 
test: Prevent test timeout error by properly closing server #2490
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
          
     Merged
      
      
    
      
        
          +71
        
        
          −57
        
        
          
        
      
    
  
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            17 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      de5deef
              
                test: Investigate integration test timeout
              
              
                dplewis b65f333
              
                Merge branch 'alpha' into improve-test
              
              
                dplewis ab724d5
              
                wait for connections to close
              
              
                dplewis 86ef802
              
                clean up
              
              
                dplewis 7b16ec7
              
                refactor shutdown server
              
              
                dplewis eaecfc2
              
                test connections
              
              
                dplewis 1b81fc5
              
                clean up
              
              
                dplewis e2fb952
              
                more checks
              
              
                dplewis ce4f2b6
              
                Merge branch 'alpha' into improve-test
              
              
                mtrezza ca92426
              
                Merge branch 'alpha' into improve-test
              
              
                mtrezza afdeb2b
              
                last attempt
              
              
                dplewis 9de8ce6
              
                move shutdown logic
              
              
                dplewis 95cb515
              
                fix tests
              
              
                dplewis 278e7fd
              
                remove afterAll
              
              
                dplewis d77f66c
              
                Merge branch 'alpha' into improve-test
              
              
                dplewis d3590ec
              
                Merge branch 'alpha' into improve-test
              
              
                dplewis d93d21a
              
                Merge branch 'alpha' into improve-test
              
              
                dplewis File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,26 +1,37 @@ | ||
| 'use strict'; | ||
| 
     | 
||
| const assert = require('assert'); | ||
| 
     | 
||
| describe('ParseServer', () => { | ||
| it('can reconfigure server', async () => { | ||
| const parseServer = await reconfigureServer({ serverURL: 'www.google.com' }); | ||
| assert.strictEqual(parseServer.config.serverURL, 'www.google.com'); | ||
| await parseServer.handleShutdown(); | ||
| await new Promise(resolve => parseServer.server.close(resolve)); | ||
| await reconfigureServer(); | ||
| let parseServer = await reconfigureServer({ serverURL: 'www.google.com' }); | ||
| expect(parseServer.config.serverURL).toBe('www.google.com'); | ||
| 
     | 
||
| await shutdownServer(parseServer); | ||
| 
     | 
||
| parseServer = await reconfigureServer(); | ||
| expect(parseServer.config.serverURL).toBe('http://localhost:1337/parse'); | ||
| }); | ||
| 
     | 
||
| it('can shutdown', async () => { | ||
| let close = 0; | ||
| const parseServer = await reconfigureServer(); | ||
| parseServer.server.on('close', () => { | ||
| close += 1; | ||
| }); | ||
| const object = new TestObject({ foo: 'bar' }); | ||
| await parseServer.handleShutdown(); | ||
| await new Promise(resolve => parseServer.server.close(resolve)); | ||
| // Open a connection to the server | ||
| const query = new Parse.Query(TestObject); | ||
| await query.subscribe(); | ||
| expect(openConnections.size > 0).toBeTruthy(); | ||
| 
     | 
||
| await shutdownServer(parseServer); | ||
| expect(close).toBe(1); | ||
| expect(openConnections.size).toBe(0); | ||
| 
     | 
||
| await expectAsync(object.save()).toBeRejectedWithError( | ||
| 'XMLHttpRequest failed: "Unable to connect to the Parse API"' | ||
| ); | ||
| await reconfigureServer({}); | ||
| await object.save(); | ||
| assert(object.id); | ||
| expect(object.id).toBeDefined(); | ||
| }); | ||
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -6,6 +6,5 @@ | |
| "spec_files": [ | ||
| "*Test.js" | ||
| ], | ||
| "random": true, | ||
| "timeout": 20000 | ||
| "random": true | ||
| } | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.